Open agliznetsov opened 9 years ago
+1
maybe it's expected? http://stackoverflow.com/questions/32147356/no-views-present-in-dist-when-building-with-grunt
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.
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
@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!!
@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'
]);
it seems like there is no way to avoid "uglify:generated"
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.