Skip to content
This repository has been archived by the owner on Apr 20, 2018. It is now read-only.

should not process comment scripts? #503

Open
JohnnyFee opened this issue Jan 8, 2015 · 6 comments
Open

should not process comment scripts? #503

JohnnyFee opened this issue Jan 8, 2015 · 6 comments

Comments

@JohnnyFee
Copy link

When I comment some sciprts in index.html:

<!-- build:js({.tmp,client}) app/app.js -->
<script src="app/app.js"></script>

<!-- Mock Code
<script src="components/mock.js"></script>
-->

<!-- endbuild -->

I use useminPrepare to generate the config, and then run the generated tasks. But the concated file will include the commented scripts components/mock.js, this is a bug?

But when I rewite the comment as a line:

<!-- Mock Code <script src="components/mock.js"></script>-->

The commented file will not included in concated file.

My config is:

// Reads HTML for usemin blocks to enable smart builds that automatically
    // concat, minify and revision files. Creates configurations in memory so
    // additional tasks can operate on them
    useminPrepare: {
      html: ['<%= yeoman.app %>/index.html'],
      options: {
        dest: '<%= yeoman.dist %>/public'
      }
    },

    // Performs rewrites based on rev and the useminPrepare configuration
    usemin: {
      html: ['<%= yeoman.dist %>/public/{,*/}*.html'],
      css: ['<%= yeoman.dist %>/public/{,*/}*.css'],
      js: ['<%= yeoman.dist %>/public/{,*/}*.js'],
      options: {
        assetsDirs: [
          '<%= yeoman.dist %>/public',
          '<%= yeoman.dist %>/public/app',
          '<%= yeoman.dist %>/public/assets/images'
        ],
        // This is so we update image references in our ng-templates
        patterns: {
          js: [
            [/(assets\/images\/.*?\.(?:gif|jpeg|jpg|png|webp|svg))/gm, 'Update the JS to reference our revved images']
          ]
        }
      }
    },
@jmaister
Copy link

I have found the same problem when commenting a JS file like this:

<!-- build:js scripts1.js -->
...
<!-- <script src="libs/angular/angular.js"></script> -->
...
<!-- endbuild -->

The file gets added to the result script even that it is commented.

@marcobiedermann
Copy link

👍

@ghost
Copy link

ghost commented Feb 1, 2015

i found it either, it is a big hole
usemin with concat your comment js
so you have to delete it not comment it

@arthurvr
Copy link
Member

Confirmed. This will be hard to fix tho, as we're using regexps to parse our HTML. This would be fixed by #244 (using an actual parser instead of regexps).

@stephanebachelier
Copy link
Collaborator

@JohnnyFee and others. I will come back to you soon as I'm already working on using an HTML parser.

@stephanebachelier
Copy link
Collaborator

Work is done in #544 and might be merged into dev branch.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

5 participants