I have a Gruntfile running concat and uglify with specific options (i.e. mangle toplevel variables) and then I use sed to update the references to the minified files in index.html. This solution works but is not very maintainable because of sed. I was trying to use usemin instead but I could not figure out how to define my own custom steps with the right options for uglifyjs and the doco lacks in examples to do that. I tried to use the same uglify task I had written before:
uglify: {
options: {
banner: '/*! <%= pkg.name %> <%= grunt.template.today("yyyy-mm-dd") %> */\n',
mangle: {
except: ['$', 'd3'],
toplevel: true
}
},
build: {
src: 'demo/js/<%= pkg.name %>.js',
dest: 'demo/js/<%= pkg.name %>.min.js'
}
},
useminPrepare : {
html : 'src/index.html',
options: {
flow: {
steps: {'js' : ['uglify'] }
}
}
}
but I am getting this error:
Warning: Cannot find module 'path-to-module\node_modules\grunt-usemin\lib\config\uglify' Use --force to continue.
Is it possible to do this and if so, what am i doing wrong here?