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