How to make grunt not minify certain js files

My grunt script generated by yeoman concats and minifies js files through useminPrepare, concat, and uglifyjs.

This is working great, but there is one js script that I do not want it to minify. How do I specify that in the grunt file?


What you can do it's to put the files you don't want to minify outside of the build script, for example:

<!-- build:js js/app.js -->
<script src="js/app.js"></script>
<script src="js/minifythis.js"></script>
<script src="js/models/minifythis.js"></script>
<!-- endbuild -->
<script src="js/do-not-minify-this.js"></script>

I spent days looking for a solution to a problem similar to yours, and then I found a different question that has a answer that may fit solve your problem, as it solved mine:

The solution is to define custom blocks to be processed by Grunt. Then you can specify one block with ['concat'] and another with ['concat', 'uglifyjs'].

If you choose to exclude the files from the minification tag per the item from John Locke, don't forget to manually copy those files to the 'dist' dir. Normally, when you minify files the resultant minified library is copied to the dist dir. But since you're not minifying them, you have to copy them yourself.

For example, I didn't want to compress the user scripts in my app to make it easier for people to examine the code online. After editing my 'index.html' to remove them from the tag:

'<!-- build:js({.tmp,app}) scripts/scripts.js -->'

I had to add the following to the copy step of my Gruntfile:

copy: {
  dist: {
    files: [
      {  // manually copy all the files you are not minimizing:
        expand: true,
        cwd: '<%= %>/scripts/',
        dest:"<%= yeoman.dist %>/scripts/"

The syntax for copying files is very prickly in Grunt. It took me a couple of tries to get it right.

Just need to set a minimize option of that script to false in Gruntfile.js.

optimization: {
    minimize: false

Need Your Help

Error in configuring tomcat in XAMPP

mysql apache tomcat xampp

I have Windows 7 installed on my PC.I have downloaded XAMPP server and installed it with it's default options. However, I noticed that Tomcat does not work (while MySQL, Apache does work!). I am tr...