Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Disable minification in Grunt (Yeoman)

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

like image 937
frazras Avatar asked Oct 19 '22 22:10

frazras


2 Answers

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.

like image 139
Brian Tingle Avatar answered Oct 21 '22 17:10

Brian Tingle


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'
       ]
     }
   }
 },
like image 31
jperezov Avatar answered Oct 21 '22 15:10

jperezov