简体   繁体   English

如何自动将常规js文件更改为min.js?

[英]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. 嗨,我该如何使用gulp,这样当我将index.html上传到服务器时,javascript文件会自身缩小。 so for development purpose I can have the regular javascript file and when its uploaded it changes to the min.js version 因此出于开发目的,我可以使用常规的javascript文件,并在其上传后将其更改为min.js版本

Another term for minify is uglify: 缩小的另一个术语是uglify:

You can read more about it here for gulp 您可以在这里阅读更多有关它的信息

https://www.npmjs.com/package/gulp-uglify 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'));
});

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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