-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathgulpfile.js
52 lines (47 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
const { series, src, dest } = require('gulp');
const useref = require('gulp-useref');
const cssnano = require('gulp-cssnano');
const gulpIf = require('gulp-if');
const babel = require('gulp-babel');
const del = require('del');
const terser = require('gulp-terser');
function clean(cb) {
del.sync('deploy');
cb();
}
function build() {
return src('src/index.html')
.pipe(useref())
.pipe(
gulpIf(
'*.js',
babel({
presets: ['@babel/env']
})
)
)
.pipe(gulpIf('*.js', terser()))
.pipe(gulpIf('*.css', cssnano()))
.pipe(dest('deploy'));
}
function buildBackground() {
return src(['src/js/background.js'])
.pipe(
gulpIf(
'*.js',
babel({
presets: ['@babel/env']
})
)
)
.pipe(gulpIf('*.js', terser()))
.pipe(dest('deploy/js'));
}
function copy(cb) {
src('src/assets/**/*').pipe(dest('deploy/assets'));
src('src/css/shared.css').pipe(dest('deploy/css'));
src('src/manifest.json').pipe(dest('deploy'));
src('src/options_page/**').pipe(dest('deploy/options_page'));
cb();
}
exports.build = series(clean, build, buildBackground, copy);