usemin define custom step options
Asked Answered
A

1

5

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?

Argumentation answered 30/10, 2013 at 15:47 Comment(0)
S
7

Try replacing uglify with uglifyjs in your flow options.

Stapleton answered 5/11, 2013 at 16:23 Comment(2)
Thank you! Console output left me with no idea what was wrong.Doak
I was searching around for related issues and found this - my case needed me to do uglifyjs > uglify here was my issue was with grunt-useminOriental

© 2022 - 2024 — McMap. All rights reserved.