javascript - How to use my own option configurations for concat and uglify with grunt-usemin -


for example: im using current configuration below uglify js scripts in gruntfile:

    uglify: {         options: {             report: "min", //"gzip",             sourcemap: true,             preservecomments: false, //"some", "all"         },         application: {             options: {                 // expand: true,                 banner: '<%= app.banner %>',                 preservecomments: "some"             },             src: 'dist/js/application.js',             dest: ".tmp/js/application.min.js"         },         dependencies: {             options: {                 sourcemap: false             },             src: ['dist/js/dependencies.js'],             dest: ".tmp/js/dependencies.min.js"         }, 

im aware grunt-usemin generates src , dest options code block in html file declared in useminprepare gruntfile option, example:

    <!-- build:js js/app.js -->     <script src="js/app.js"></script>     <script src="js/controllers/thing-controller.js"></script>     <script src="js/models/thing-model.js"></script>     <script src="js/views/thing-view.js"></script>     <!-- endbuild --> 

so how can configure grunt-usemin use these same options, such banner, sourcemap: false generated file blocks, i've read through quick documentation given in github or npm registry seem not find solid answer this.

one sentence important in documentation :

in addition, useminprepare dynamically generates configuration concat, uglify, , cssmin. important: still need manually manage these dependencies , call each task.

the principle declare want use usemin (in grunt register task) main task want : concat, uglify... usemin default create these tasks without anymore declaration, based on registertask options , html markup comments.

code better words :

  1. express block markup target files. in case :
     <!-- build:js js/app.min.js -->      <script src="js/app.js"></script>      <script src="js/controllers/thing-controller.js"></script>      <script src="js/models/thing-model.js"></script>      <script src="js/views/thing-view.js"></script>      <!-- endbuild --> 

2 - register tasks want usemin generates during runtime (it not generate in file - should precised in documentation). example :

grunt.registertask('minify', [ 'useminprepare' ,'concat' ,'cssmin' ,'uglify' ,'copy'
,'rev ,'usemin' ])

3 - default, these tasks generated except useminprepare , usemin (look @ documentation these 2 blocks grunt-usemin).

then if want add specific options sourcemap, rewrite configuration code without redefining :

uglify: { options: { sourcemap: false } }

hope helps.


Comments

Popular posts from this blog

PHPMotion implementation - URL based videos (Hosted on separate location) -

javascript - Using Windows Media Player as video fallback for video tag -

c# - Unity IoC Lifetime per HttpRequest for UserStore -