-
Notifications
You must be signed in to change notification settings - Fork 0
/
gulpfile.js
93 lines (80 loc) · 2.4 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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
/**
* gulp依赖
* npm install --save-dev gulp gulp-minify-css gulp-autoprefixer gulp-sourcemaps gulp-jshint gulp-uglify gulp-rename gulp-concat gulp-clean gulp-webpack
*/
var gulp = require('gulp'),
minifycss = require('gulp-minify-css'),
autoprefixer = require('gulp-autoprefixer'),
jshint = require('gulp-jshint'),
uglify = require('gulp-uglify'),
rename = require('gulp-rename'),
sourcemaps = require('gulp-sourcemaps'),
gulpwebpack = require('gulp-webpack'),
webpack = require('webpack'),
concat = require('gulp-concat'),
clean = require('gulp-clean');
var notify = require("gulp-notify");
var markdown = require('gulp-markdown');
/**
* 删除css
*/
gulp.task('clean-css', function(){
return gulp.src('./public/css/app.min.css')
.pipe(clean());
});
/**
* 合并css
*/
gulp.task('css', ['clean-css'], function(){
return gulp.src('./src/css/app.css')
.pipe(sourcemaps.init())
.pipe(minifycss({rebase: false, advanced: false, keepBreaks: true}))
.pipe(autoprefixer())
.pipe(sourcemaps.write())
.pipe(rename('app.min.css'))
.pipe(gulp.dest('./public/css/'));
});
/**
* 删除js
*/
gulp.task('clean-js', function(){
return gulp.src('./public/js/+(app|lib)?(.min).js')
.pipe(clean());
});
/**
* webpack 编译
*/
gulp.task('webpack', ['clean-js'], function(cb){
return gulp.src('./src/app/+(app|lib).js')
.pipe(gulpwebpack( require('./webpack.config.js') ))
.pipe(gulp.dest('./public/js/'))
});
/**
* 压缩js
*/
gulp.task('js', ['webpack'], function(){
return gulp.src('./public/js/+(app|lib).js')
// .pipe(jshint())
// .pipe(uglify())
.pipe(rename({suffix: ".min"}))
.pipe(gulp.dest('./public/js/'))
.pipe(notify('<%= file.relative %> build done!'));
});
gulp.task("watch", ['default'], function(){
gulp.watch('./src/**/**.vue', ['js']);
gulp.watch('./src/**/**.js', ['js']);
gulp.watch('./src/css/**.css', ['css']);
});
gulp.task('default', ['css', 'js']);
gulp.task('uglify', ['default'], function(){
return gulp.src('./public/js/+(app|lib).js')
.pipe(uglify())
.pipe(rename({suffix: ".min"}))
.pipe(gulp.dest('./public/js/'));
})
gulp.task('md', function () {
return gulp.src('release-note.md')
.pipe(markdown())
.pipe(rename('release-note.html'))
.pipe(gulp.dest('./'));
});