Is it possible to specify and array of files that I want compressed and mangled (default Uglify behavior), but also a list of files that should not be touched, just concatenated?
Thanks.
You can solve this in different ways. I'm posting an extended example to illustrate what one can do:
uglify: {
doAll: {
options: {
banner: '// <%= pkg.name %> - v<%= pkg.version %> - ' + '<%= grunt.template.today("yyyy-mm-dd HH:mm:ss") %>\n\n',
mangle: {
except: [ // mangle is true for all else besides the specified exceptions
'src/input-d.js',
'src/input-e.js',
'src/input-f.js'
]
},
preserveComments: 'some'
},
files: 'dest/output.min.js': [ // concatenation, uglification (mangle) with exceptions, block comments preserved, minification and a banner
'src/input-a.js',
'src/input-b.js',
'src/input-c.js',
'src/input-d.js',
'src/input-e.js',
'src/input-f.js'
]
},
concatenateOnly: {
options: {
compress: false,
mangle: false,
preserveComments: 'all'
},
files: 'dest/output.js': [ // only concatenation
'src/input-a.js',
'src/input-b.js',
'src/input-c.js',
'src/input-d.js',
'src/input-e.js',
'src/input-f.js'
]
}
}
The concatenateOnly
task would do exactly what you wanted, only concatenate. You could specify which files would be concatenated there. You could run both concatenateAll
and doAll
at the same time by using the watch
task:
watch: {
js: {
files: ['config/*.js', 'app/js/**/*.js'],
tasks: ['jshint', 'jasmine', 'uglify:concatenateOnly', 'uglify:doAll']
}
}
...or you could do a single task by combining some of the settings I pasted above, like using the options.mangle.except
to your benefit.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With