缩小后如何将缩小的脚本保存到相同的源文件中

时间:2018-07-11 11:38:23

标签: gulp gulp-watch gulp-uglify gulp-concat gulp-sourcemaps

这是我使用的格式! minification运行正常。例如,我在源文件中有一个名为test.jstest1.js的文件。我想minify test.js,并想在同一minified

中替换test.js文件
var gulp = require('gulp');
var coffee = require('gulp-coffee');
var concat = require('gulp-concat');
var uglify = require('gulp-uglify');
var sourcemaps = require('gulp-sourcemaps');
var del = require('del');

var paths = {
  scripts: ['modules/*/client/*.js', '!client/external/**/*.coffee'],

};

// Not all tasks need to use streams
// A gulpfile is just another node program and you can use any package available on npm
gulp.task('clean', function() {
  // You can use multiple globbing patterns as you would with `gulp.src`
  return del(['build']);
});

gulp.task('scripts', ['clean'], function() {
  // Minify and copy all JavaScript (except vendor scripts)
  // with sourcemaps all the way down
  return gulp.src(paths.scripts)
    .pipe(sourcemaps.init())
      .pipe(coffee())
      .pipe(uglify())

    .pipe(sourcemaps.write())
    .pipe(gulp.dest('test'));
});
// The default task (called when you run `gulp` from cli)
gulp.task('default', ['scripts']);

0 个答案:

没有答案