forked from shinygang/Vue-cnodejs
-
Notifications
You must be signed in to change notification settings - Fork 0
/
gulpfile.js
53 lines (45 loc) · 1.08 KB
/
gulpfile.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
'use strict'
var gulp = require('gulp'),
minifycss = require('gulp-minify-css'),
uglify = require('gulp-uglify'),
webpack = require('webpack'),
rename = require('gulp-rename'),
del = require('del');
var config = require('./webpack.config');
/**
* 清理生产目录文件
*/
gulp.task('clean', function(cb) {
del(['./dist/*.js','./dist/*.css','./dist/*.map']).then(paths => {
console.log('Deleted files and folders:\n', paths.join('\n'));
cb();
});
});
/**
* 执行webpack打包
*/
gulp.task('webpack',['clean'], function(cb) {
webpack(config, cb)
});
/**
* 压缩css文件
*/
gulp.task('style',function() {
gulp.src('./dist/style.css')
.pipe(rename({suffix:'.min'}))
.pipe(minifycss())
.pipe(gulp.dest('dist'));
});
/**
* 压缩js文件
*/
gulp.task('script',function(){
gulp.src('./dist/*.js')
// .pipe(rename({suffix:'.min'}))
.pipe(uglify())
.pipe(gulp.dest('dist'));
});
gulp.task('default', ['webpack'], function() {
console.log(process.env.NODE_ENV);
gulp.start('style','script')
})