简体   繁体   中英

How to change regular js file to min.js automatically?

Hi how can i use gulp so that when I upload my index.html to the server, the javascript file gets the minified by itself. so for development purpose I can have the regular javascript file and when its uploaded it changes to the min.js version

Another term for minify is uglify:

You can read more about it here for gulp

https://www.npmjs.com/package/gulp-uglify

Usage

var uglify = require('gulp-uglify');

gulp.task('compress', function() {
  return gulp.src('lib/*.js')
    .pipe(uglify())
    .pipe(gulp.dest('dist'));
});

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