fra*_*ras 5 javascript minify gruntjs grunt-contrib-uglify
我最近开始通过Yeoman使用GruntJS,我喜欢Javascript缩小的想法,但它在开发过程中遇到了困难.我试图在Gruntfile中以不同的组合禁用uglify,usemin等,但是一切似乎都依赖于另一件事并打破了这个过程.有没有简单的方法来禁用缩小?我使用Yeoman提供的最新版本的Grunt,我发现旧的解决方案与使用Yeoman的用户有不同的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'
},
Run Code Online (Sandbox Code Playgroud)
此评论块位于您的 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.
Run Code Online (Sandbox Code Playgroud)
基于此,<!-- Usemin block -->从您的 index.html 文件中删除 应该可以防止useminPreparegrunt 任务缩小您的 JavaScript。
此外,您可以通过添加文件扩展名来编辑uglify任务以创建新文件,以免覆盖您的开发文件:.min
uglify: {
dist: {
files: {
'<%= config.dist %>/scripts/scripts.js': [
'<%= config.dist %>/scripts/scripts.min.js'
]
}
}
},
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
2753 次 |
| 最近记录: |