-
Notifications
You must be signed in to change notification settings - Fork 0
/
gulpfile-build.js
58 lines (58 loc) · 1.49 KB
/
gulpfile-build.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
const gulp=require('gulp');
const server=require('gulp-webserver');
const sass=require('gulp-sass');
const webpack=require('webpack-stream');
const sequence=require('gulp-sequence');
const proxy=require('http-proxy-middleware');
const babel=require('gulp-babel');
const minifycss=require('gulp-minify-css');
const minifyhtml=require('gulp-minify-html');
const uglify=require('gulp-uglify');
const del=require('del');
const rev=require('gulp-rev');
const revCollector=require('gulp-rev-collector');
gulp.task('scss',()=>{
return gulp.src('./src/styles/*.scss')
.pipe(sass().on('error',sass.logError))
.pipe(rev())
.pipe(minifycss())
.pipe(gulp.dest('./dist/styles'))
.pipe(rev.manifest())
.pipe(gulp.dest('./dist/rev/styles'))
})
gulp.task('html',()=>{
return gulp.src('./*.html')
.pipe(revCollector({
replaceReved:true
}))
.pipe(minifyhtml())
.pipe(gulp.dest('./dist'))
})
gulp.task('js',()=>{
return gulp.src('./src/scripts/app.js')
.pipe(webpack({
entry:'./src/scripts/app.js',
output:{
filename:'app.js'
}
}))
.pipe(babel({
presets:['env']
}))
.pipe(uglify())
.pipe(rev())
.pipe(gulp.dest('./dist/scripts'))
.pipe(rev.manifest())
.pipe(gulp.dest('./dist/rev/scripts'))
})
gulp.task('lib',()=>{
return gulp.src('./src/libs/*.js')
.pipe(gulp.dest('./dist/libs'))
})
gulp.task('clear',del.bind(null,['./dist/**/*'],{
force:true
}))
gulp.task('default',(cb)=>{
sequence('clear',['js','scss'],['html','lib'])(cb)
console.log('done');
})