ericclemmons / grunt-angular-templates

Grunt build task to concatenate & pre-load your AngularJS templates
MIT License
710 stars 107 forks source link

usemin option doesn't work #70

Closed Hotell closed 8 years ago

Hotell commented 10 years ago

Hi, trying to append templates to final script file via usemin option but it doesn't work:

(I'm using Yeoman)

Here is HTML snippet

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

Gruntfile:

  // compiles templates to cache
      ngtemplates: {
          dist: {
              options: {
                  module: 'testApp',
                  usemin: 'scripts/scripts.js'
              },
              cwd: '<%= yeoman.app %>',
              src: 'views/**/*.html',
              dest: '<%= yeoman.app %>/scripts/templates.js'
          }
      }
...
...
// build task
grunt.registerTask('build', [
    'clean:dist',
    'bower-install',
    'useminPrepare',
    'ngtemplates',
    'concurrent:dist',
    'autoprefixer',
    'concat',
    'ngmin',
    'copy:dist',
    'cdnify',
    'cssmin',
    'uglify',
    'rev',
    'usemin',
    'htmlmin'
  ]);

when running task:

$ grunt build

grunt throws this error:

Running "ngtemplates:dist" (ngtemplates) task
File dist/scripts/templates.js created.
>> Could not find usemin.generated path matching: scripts/scripts.js
ericclemmons commented 10 years ago

Can you run grunt build --verbose and (hopefully) see what usemin is generating for the concat task? That'll help immensely! (usemin usually spits out the generated config when ran)

Hotell commented 10 years ago

Sure, here it is Oh and btw ( I'm on Windows machine ) thanks

concat:
  { generated:
   { files:
      [ { dest: '.tmp\\concat\\styles\\vendor.css',
          src: [ 'app\\bower_components\\bootstrap\\dist\\css\\bootstrap.css' ] },
        { dest: '.tmp\\concat\\styles\\main.css',
          src: [ '{.tmp,app}\\styles\\main.css' ] },
        { dest: '.tmp\\concat\\scripts\\vendor.js',
          src:
           [ 'app\\bower_components\\angular\\angular.js',
             'app\\bower_components\\angular-resource\\angular-resource.js',
             'app\\bower_components\\angular-cookies\\angular-cookies.js',
             'app\\bower_components\\angular-sanitize\\angular-sanitize.js',
             'app\\bower_components\\angular-route\\angular-route.js',
             'app\\bower_components\\angular-bootstrap\\ui-bootstrap-tpls.js' ] },
        { dest: '.tmp\\concat\\scripts\\scripts.js',
          src:
           [ '{.tmp,app}\\scripts\\app.js',
             '{.tmp,app}\\scripts\\controllers\\main.js' ] } ] } }

  uglify:
  { generated:
   { files:
      [ { dest: 'dist\\scripts\\vendor.js',
          src: [ '.tmp\\concat\\scripts\\vendor.js' ] },
        { dest: 'dist\\scripts\\scripts.js',
          src: [ '.tmp\\concat\\scripts\\scripts.js' ] } ] } }

  cssmin:
  { generated:
   { files:
      [ { dest: 'dist\\styles\\vendor.css',
          src: [ '.tmp\\concat\\styles\\vendor.css' ] },
        { dest: 'dist\\styles\\main.css',
          src: [ '.tmp\\concat\\styles\\main.css' ] } ] } }
ericclemmons commented 10 years ago

ah HA! So, two things are at play here. My path lookup is expecting scripts/scripts.js and you're on Windows.

The second may be the optional paths ({.tmp,app}), but I won't know for sure.

Have you tried changing it to scripts\scripts.js or scripts\\scripts.js, since you're on Windows? That may fix it.

Hotell commented 10 years ago

yay! you're da man :) works, maybe you should put that in docs for other windows users or fix it to resolve the path without this win hack.

many thanks

ericclemmons commented 10 years ago

Very good point! Which one worked? \ or \\?

Hotell commented 10 years ago

of course double back slash \\ if it would be just one it would just escape the next character. so scripts\script.js would be interpreted like scriptscriptjs

thanks again.

niyando commented 9 years ago

totally unrelated, @Hotell whats your workflow when you serve app locally? Do you need to reference template.js in index.html?

underscorebrody commented 8 years ago

Closing this, I think it is resolved

kadosh1000 commented 8 years ago

Having the same issue on windows machine, changing to double backslash didn't fix it either

abe312 commented 6 years ago

resolved this issue. Looks like I was missing <!-- endbuild --> in the js section of index.html

Please recheck the same. Hope it solves the problem :)