Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unable to use with usemin and no uglify step #129

Open
agliznetsov opened this issue Sep 2, 2015 · 6 comments
Open

Unable to use with usemin and no uglify step #129

agliznetsov opened this issue Sep 2, 2015 · 6 comments

Comments

@agliznetsov
Copy link

I'm using yeoman angular project template but my usemin task has no uglify step, only concat.

Here's my config:
ngtemplates: {
dist: {
cwd: 'app',
src: 'views/{,/}.html',
dest: '.tmp/templateCache.js',
options: {
module: 'myApp',
usemin: 'scripts/app.js'
}
}
},
During the build the generated templateCache.js is not added to the app.js and I see this error message: Usemin has not created uglify.generated yet!

When I changed the config to this:
options: {
module: 'myApp',
concat: 'generated',
}
it works but templateCache gets added to both app.js and vendor.js.

@Hendler
Copy link

Hendler commented Dec 17, 2015

@fvanwijk
Copy link

I have the same. It gives the error:

Usemin has not created uglify.generated yet!

It looks like you have to concat the templates yourself in the concatted (non-uglified) output, but it will make usemin pretty useless.

@achyutjhunjhunwala
Copy link

Well same issue, i have register 2 tasks, 1 for development purpose 1 for deployment.
For the development one, i have removed the uglify from usemin.

But now ngTemplate is expecting uglify:generated. ngAnnotate should not expect for usemin dependencies so strictly

@mhawila
Copy link

mhawila commented Apr 16, 2016

@fvanwijk What did you about this? I am facing the same issue.

--Update--
I removed node_modules directory and rerun npm install. It worked. So weirdo though!!

@fvanwijk
Copy link

fvanwijk commented Apr 16, 2016

@mhawila It seems that grunt-angular-template and especially grunt-usemin (unmaintained) is really an all-or-nothing solution. Custom configuration still has a lot of quirks.

I only do concat and ngtemplates with usemin. The buildjs annotations in index.html already contain xxx.min.js. Since the uglify task is not related to prepareUsemin anymore, it has its own config.
I also concat the templateCache manually with an extra step.

Eventually I want to get rid of Grunt build tasks such as usemin, since ES6 modules with eg. Webpack give a lot more configuration freedom and a better project structure. I see usemin as a deprecated solution.

Note that when you use Webpack, you load bundle.js in a script tag in both development and production template, so there is no need voor template rewriting using grunt-angular-templates anymore.

For completeness, this is my config, cleaned up for readibility, hope it still works for you:

{
  concat: {
    templates: {
      files: {
        'dist/scripts/scripts.min.js': [paths.dist + '/scripts/scripts.min.js', '.tmp/scripts/templateCache.js'],
      }
    }
  },
  cssmin: {
    dist: {
      files: [{
        expand: true,
        cwd: paths.dist + '/styles',
        src: '**/*.css',
        dest: paths.dist + '/styles'
      }]
    }
  },
  htmlmin: {
    dist: {
      files: [{
        expand: true,
        cwd: paths.app,
        src: ['*.html'],
        dest: paths.dist
      }]
    }
  },
  ngtemplates: {
    dist: {
      files: [{
        cwd: '.tmp/app',
        src: 'scripts/**/*.html',
        dest: '.tmp/scripts/templateCache.js'
      }]
    }
  },
  uglify: {
    dist: {
      files: [{
        expand: true,
        cwd: paths.dist + '/scripts',
        src: '*.js',
        dest: paths.dist + '/scripts'
      }]
    }
  },
  usemin: {
    html: [paths.dist + '/**/*.html'],
    options: {
      dirs: [paths.dist + '']
    }
  },
  useminPrepare: {
    dist: [paths.app + '/*.html'],
    options: {
      dest: paths.dist,
      flow: {
        steps: {
          // Do not run 'cssmin' and 'uglify'. We do it separately for non-lib css/js files
          js: ['concat'],
          css: ['concat']
        }
      }
    }
  }
},

Build task:

grunt.registerTask('build', [
    'useminPrepare',
    'concat:generated',

    // Must run after concat:generated but before rev. See https://github.com/ericclemmons/grunt-angular-templates/issues/129
    'ngtemplates',
    'concat:templates',

    'rev',
    'htmlmin',
    'usemin',
    'cssmin',
    'uglify'
  ]);

@alexey-sh
Copy link

it seems like there is no way to avoid "uglify:generated"

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

No branches or pull requests

6 participants