forked from MaxLaumeister/ToneMatrixRedux
-
Notifications
You must be signed in to change notification settings - Fork 0
/
gulpfile.js
108 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
99
100
101
102
103
104
105
106
107
108
const {
src, dest, parallel, series, watch,
} = require('gulp');
const uglify = require('gulp-uglify-es').default;
const browserSync = require('browser-sync').create();
const del = require('del');
const concat = require('gulp-concat');
const sourcemaps = require('gulp-sourcemaps');
const noop = require('gulp-noop');
const sass = require('gulp-sass');
const jsdoc = require('gulp-jsdoc3');
const eslint = require('gulp-eslint');
const sassLint = require('gulp-sass-lint');
function html() {
return src('src/*.html')
.pipe(dest('dist'));
}
function js(minify) {
return src(['lib/*.js', 'src/*.js'])
.pipe(sourcemaps.init())
.pipe(concat('all.js'))
.pipe(minify ? uglify() : noop())
.pipe(dest('dist', { sourcemaps: !minify }));
}
function jslint() {
return src(['*.js', 'src/*.js'])
.pipe(eslint({
configFile: '.eslintrc.js',
}))
.pipe(eslint.format());
}
function scsslint() {
return src(['src/*.scss'])
.pipe(sassLint())
.pipe(sassLint.format());
}
function lint(done) {
return parallel(jslint, scsslint)(done);
}
function jsmin() {
return js(true);
}
function jsconcat() {
return js(false);
}
function css(sourcemap) {
return src('src/*.scss')
.pipe(sourcemap ? sourcemaps.init() : noop())
.pipe(sass())
.pipe(dest('dist', { sourcemaps: sourcemap }));
}
function cssWithSourcemaps() {
return css(true);
}
function cssWithoutSourcemaps() {
return css(false);
}
function staticdir() {
return src('static/*')
.pipe(dest('dist'));
}
function docs(done) {
return src(['README.md', './src/*.js'])
.pipe(jsdoc(done));
}
function dev(done) {
return parallel(html, cssWithSourcemaps, jsconcat, staticdir, lint, docs)(done);
}
function prod(done) {
return parallel(html, cssWithoutSourcemaps, jsmin, staticdir)(done);
}
function serve(done) {
browserSync.init({
browser: 'chrome',
server: {
baseDir: './dist',
},
ghostMode: false,
});
done();
}
const clean = () => del(['dist']);
const dowatch = () => watch(['lib', 'src', 'static'], series(dev /* , reload */));
exports.clean = clean;
exports.dev = dev;
exports.prod = prod;
exports.lint = lint;
exports.serve = series(clean, dev, serve, dowatch);
exports.docs = docs;