forked from liyasthomas/mnmlurl
-
Notifications
You must be signed in to change notification settings - Fork 0
/
gulpfile.js
75 lines (75 loc) · 1.98 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
let gulp = require('gulp')
let browserify = require('browserify')
let htmlmin = require('gulp-htmlmin')
let postcss = require('gulp-postcss')
let cssnano = require('cssnano')
let uglify = require('gulp-uglify')
let babel = require('gulp-babel')
let del = require('del')
let zip = require('gulp-zip')
let source = require('vinyl-source-stream')
const compress = () => gulp
.src('output/*')
.pipe(zip('package.zip'))
.pipe(gulp.dest('output'))
const pre_js = () => gulp
.src(['src/index.js', 'src/manage.js', 'src/head.js'])
.pipe(babel({
plugins: ['@babel/transform-runtime'],
presets: ['@babel/preset-env']
}))
.pipe(gulp.dest('comp'))
const m_html = () => gulp
.src(['src/index.html', 'src/manage.html', 'src/404.html'])
.pipe(htmlmin({
collapseWhitespace: true
}))
.pipe(gulp.dest('output'))
const m_css = () => {
const plugins = [
cssnano()
]
return gulp
.src('src/index.css')
.pipe(postcss(plugins))
.pipe(gulp.dest('output'))
}
const m_js = () => gulp
.src(['comp/index.js', 'comp/manage.js', 'comp/head.js'])
.pipe(uglify({
compress: {
unused: false
}
}))
.pipe(gulp.dest('output'))
const copy_extras = () => gulp
.src(['src/manifest.json', 'src/favicon.ico', 'src/icons/*', 'src/sw.js'], {
base: 'src'
})
.pipe(gulp.dest('output'))
const clean = () => del(['./comp'])
const bundleindex = () => browserify(['output/index.js'])
.bundle()
.pipe(source('index.js'))
.pipe(gulp.dest('output'))
const bundlemanage = () => browserify(['output/manage.js'])
.bundle()
.pipe(source('manage.js'))
.pipe(gulp.dest('output'))
gulp.task('html', m_html)
gulp.task('css', m_css)
gulp.task('js', m_js)
gulp.task('pre_js', pre_js)
gulp.task('clean', clean)
gulp.task('copy_extras', copy_extras)
gulp.task('compress', compress)
gulp.task('bundleindex', bundleindex)
gulp.task('bundlemanage', bundlemanage)
gulp.task(
'build',
gulp.series('html', 'css', 'pre_js', 'js', 'bundleindex', 'bundlemanage', 'copy_extras', 'clean')
)
gulp.task(
'packit',
gulp.series('build', 'compress')
)