[英]Angular “Unknown Provider” error after minification with Grunt Build in Yeoman app
[英]Disable minification in Grunt (Yeoman)
我最近开始通过Yeoman使用GruntJS,我喜欢Javascript缩小的想法,但它在开发过程中遇到了困难。 我试图在Gruntfile中以不同的组合禁用uglify,usemin等,但是一切似乎都依赖于另一件事并打破了这个过程。 有没有简单的方法来禁用缩小? 我正在使用Yeoman提供的最新版本的Grunt,我发现旧的解决方案具有与使用Yeoman的usd不同的Gruntfile设置。
这是我的Gruntfile:
// 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: {
options: {
dest: '<%= config.dist %>'
},
html: '<%= config.app %>/index.html'
},
我需要调整usemin flow:
选项:
根据yeoman grunt usemin的精细手册 ,默认flow:
是
{ steps: { js: ['concat', 'uglify'], css: ['concat', 'cssmin'] }, post: {} }
这里是我如何修改要点我哟web应用Gruntfile.js
删除uglify
从流。
这个评论块在你的Gruntfile中:
// By default, your `index.html`'s <!-- Usemin block --> will take care
// of minification. These next options are pre-configured if you do not
// wish to use the Usemin blocks.
基于此,从index.html文件中删除<!-- Usemin block -->
应该可以防止useminPrepare
grunt任务缩小你的javascript。
此外,您可以编辑uglify
任务以创建新文件,以通过将.min
添加到文件扩展名来覆盖您的dev文件:
uglify: {
dist: {
files: {
'<%= config.dist %>/scripts/scripts.js': [
'<%= config.dist %>/scripts/scripts.min.js'
]
}
}
},
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.