简体   繁体   中英

Is it possible to only minify unminified JS files with grunt uglify

I want to use this grunt uglify setup shown in the accepted answer here: How to minify multiple Javascript files in a folder with UglifyJS?

However I only want to run it on files that are unminified, can uglify check this or not?

If not, any way of making it do this? Either by checking the size of the file/number of lines or maybe just checking if the file name ends in '.min.js'

When you set the src for the uglify task to

src: ['js/*.js', '!js/*.min.js'],

All the .min.js files are not processed by uglify.

See also: http://gruntjs.com/configuring-tasks#globbing-patterns

You need to follow these build steps:

  1. Minify only the unminified assets by using a specific globbing pattern (like the one suggested by @Qurben) src: ['js/*.js', '!js/*.min.js']
  2. You need to CONCAT the already minified files along with the newly [your] minified application to produce the final result.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM