Skip to content

Comments should be stripped from bundles #4

@mikecao

Description

@mikecao

When bundling with glslify, comments are not removed from the final source string. I'm trying to the output to be as packed as possible. I am currently using a custom function in my own fork of glslify-bundle that does the trick:

function strip_comments(tokens) {
  for (var i = 1; i < tokens.length; i++) {
    var token = tokens[i]
    if (token.type == 'block-comment' || token.type == 'line-comment') {
      tokens.splice(i--, 1);
    }
  }

  return tokens
}

then in the Bundle function I just do:

this.src = string(clean(strip_comments(trim(tokenize(this.src), true))))

Would you accept a PR for this change?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions