您的问题与usemin有关,请参阅此处的文档:
https://github.com/yeoman/grunt-usemin
只需将index.html中的注释替换为:
<!-- build:js(./) /dashboard/scripts/vendor.js -->
这意味着:
<!-- build:PATH_WHERE_TO_FIND_FILES DESTINATION_PATH -->
要用ngAnnotate替换ngmin,请执行以下操作:
修改您的Gruntfile:
替换:
// ngmin tries to make the code safe for minification automatically by
// using the Angular long form for dependency injection. It doesn't work on
// things like resolve or inject so those have to be done manually.
ngmin: {
dist: {
files: [{
expand: true,
cwd: '.tmp/concat/scripts',
src: '*.js',
dest: '.tmp/concat/scripts'
}]
}
},
通过
ngAnnotate: {
options: {
singleQuotes: true
},
dist: {
files: [{
expand: true,
cwd: '.tmp/concat/scripts',
src: '*.js',
dest: '.tmp/concat/scripts'
}]
}
},
并替换:
grunt.registerTask('build', [
'clean:dist',
'wiredep',
'useminPrepare',
'concurrent:dist',
'autoprefixer',
'concat',
'ngmin',
'copy:dist',
'cdnify',
'cssmin',
'uglify',
'filerev',
'usemin',
'htmlmin'
]);
签署人:
grunt.registerTask('build', [
'clean:dist',
'wiredep',
'useminPrepare',
'concurrent:dist',
'autoprefixer',
'concat',
'ngAnnotate',
'copy:dist',
'cdnify',
'cssmin',
'uglify',
'filerev',
'usemin',
'htmlmin'
]);
运行以下两个命令来修改package.json:
1.npm卸载grut ngmin--保存
2.npm安装grut ng注释--保存