-
Notifications
You must be signed in to change notification settings - Fork 36
/
gulpfile.babel.js
67 lines (54 loc) · 1.42 KB
/
gulpfile.babel.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
'use strict'
import gulp from 'gulp'
import browserify from 'browserify'
import babelify from 'babelify'
import source from 'vinyl-source-stream'
import jshint from 'gulp-jshint'
import minifyCss from 'gulp-minify-css'
import imagemin from 'gulp-imagemin'
import uglify from 'gulp-uglify'
import less from 'gulp-less'
import concat from 'gulp-concat'
import rename from 'gulp-rename'
gulp.task('scripts', () => {
return browserify("js/index.js")
.transform("babelify")
.bundle()
.pipe(source("index.js"))
.pipe(gulp.dest("./build/js"))
})
gulp.task('scripts-opt', () => {
return browserify("js/options.js")
.transform("babelify")
.bundle()
.pipe(source("options.js"))
.pipe(gulp.dest("./build/js"))
})
gulp.task('build', ['scripts','scripts-opt'],() => {
gulp.src(['./build/js/index.js','./build/js/options.js'])
.pipe(rename({
'suffix': '-min'
}))
.pipe(uglify())
.pipe(gulp.dest('./build/js'))
})
gulp.task('css', () => {
gulp.src('css/*.less')
.pipe(less())
.pipe(gulp.dest('./build/css/'))
.pipe(minifyCss())
.pipe(rename({
'suffix': '-min'
}))
.pipe(gulp.dest('./build/css/'))
})
gulp.task('img', () => {
gulp.src('img/*')
.pipe(imagemin())
.pipe(gulp.dest('./build/img'))
})
gulp.task('default', () => {
gulp.watch('css/*.less', ['css'])
gulp.watch('js/*.js', ['scripts','scripts-opt'])
gulp.watch('img/*.png', ['img'])
})