Disable minification in Grunt (Yeoman)

梦想的初衷 提交于 2019-12-05 10:36:38

This comment block was in your 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.

Based on this, removing the <!-- Usemin block --> from your index.html file should prevent the useminPrepare grunt task from minifying your javascript.

Additionally, you can edit your uglify task to create new files to not overwrite your dev files by adding .min to the file extension:

 uglify: {
   dist: {
     files: {
       '<%= config.dist %>/scripts/scripts.js': [
         '<%= config.dist %>/scripts/scripts.min.js'
       ]
     }
   }
 },

I needed to tweak the usemin flow: option:

as per yeoman grunt usemin's fine manual, the default flow: is

{ steps: { js: ['concat', 'uglify'], css: ['concat', 'cssmin'] }, post: {} }

Here is a gist of how I modified my yo webapp Gruntfile.js to remove uglify from the flow.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!