这是我使用的格式!
minification
运行正常。例如,我在源文件中有一个名为test.js
和test1.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']);