Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

usemin define custom step options

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?

like image 558
Renaud Avatar asked Oct 30 '13 15:10

Renaud


1 Answers

Try replacing uglify with uglifyjs in your flow options.

like image 170
rharper Avatar answered Dec 28 '22 03:12

rharper