-
Notifications
You must be signed in to change notification settings - Fork 0
/
gulpfile.js
98 lines (89 loc) · 2.2 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
90
91
92
93
94
95
96
97
98
const { src, dest, series, parallel } = require("gulp");
var ts = require("gulp-typescript");
var exec = require('child_process').exec;
var browserSync = require('browser-sync').create();
const gzip = require('gulp-gzip');
var del = require('del');
var sass = require('gulp-sass');
const cleanCSS = require('gulp-clean-css');
const terser = require('gulp-terser');
sass.compiler = require('node-sass');
var tsProject = ts.createProject("tsconfig.json");
var replace = require('gulp-replace');
function clean() {
return del([
'build/**', '!build',
'dist/**', '!dist'
], {force:true});
}
function styles() {
return src('./src/scss/**/*.scss')
.pipe(sass({
includePaths: ['node_modules'],
outputStyle: 'compressed'
}))
.pipe(sass.sync().on('error', sass.logError))
.pipe(dest('./build/css'))
.pipe(cleanCSS())
.pipe(dest("./dist/css/"))
.pipe(gzip())
.pipe(dest("./dist/css/"));
}
function samples() {
return src('./src/samples/*.js')
.pipe(dest('build/samples'))
.pipe(dest('dist/samples'));
}
function workers() {
return src('./src/workers/*.js')
.pipe(dest('build/workers'))
.pipe(dest('dist/workers'));
}
function markup() {
return src('./src/*.html')
.pipe(dest('build/'))
.pipe(replace('./', 'https://unpkg.com/@netpoint-gmbh/mochaterial/'))
.pipe(dest('dist/'));
}
function compile() {
return tsProject.src()
.pipe(tsProject())
.js.pipe(dest("./src/"));
}
function rollup(cb) {
return exec('rollup --config', function (err, stdout, stderr) {
console.log(stdout);
console.log(stderr);
cb(err);
});
}
function minifyjs() {
return src('./build/*.*js')
.pipe(terser())
.pipe(dest('dist/'))
.pipe(gzip())
.pipe(dest('dist/'));
}
function prepPublish() {
// We're releasing from dist, so copy assets there...
return src(['package.json', 'readme.md'])
.pipe(dest('dist'));
}
function server() {
browserSync.init({
server: {
baseDir: "./build"
}
});
}
const build =
series(
clean,
parallel(styles, compile, samples, workers, markup, prepPublish),
rollup,
minifyjs
);
exports.styles = styles;
exports.build = build;
exports.default = build;
exports.dev = server;