I recently started using GruntJS through Yeoman and I like the idea of Javascript minification, but it presents difficulties during development. I tried to disable uglify,usemin, etc in different combinations in the Gruntfile but everything seems to be dependent on another thing and breaks the process. Is there a simple way to disable minification? I am using the latest versionof Grunt offered by Yeoman to date, I found that older solutions have a different Gruntfile setup than that usd with Yeoman.
Here is my 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'
},
http://hastebin.com/gicabukojo.js
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.