forked from mdbassit/Coloris
-
Notifications
You must be signed in to change notification settings - Fork 0
/
gulpfile.babel.js
56 lines (46 loc) · 1.18 KB
/
gulpfile.babel.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
import { src, dest, parallel, series, watch } from 'gulp';
import babel from 'gulp-babel';
import uglify from 'gulp-uglify';
import cleanCSS from 'gulp-clean-css';
import rename from 'gulp-rename';
import replace from 'gulp-replace';
const path = {
src: './src/*',
dist: './dist',
js: './src/*.js',
css: './src/*.css'
};
function minifyJS() {
return src(path.js)
.pipe(babel({ retainLines: true }))
.pipe(replace('"use strict";', ''))
// Output the non-minified version
.pipe(dest(path.dist))
// Minify and rename to *.min.js
.pipe(uglify({
output: {
comments: /^!/
}
}))
.pipe(rename(function (path) {
path.basename += '.min';
}))
.pipe(dest(path.dist));
}
function minifyCSS() {
return src(path.css)
.pipe(cleanCSS())
.pipe(rename(function (path) {
path.basename += '.min';
}))
.pipe(dest(path.dist));
}
function copySourceCSS() {
return src(path.css).pipe(dest(path.dist));
}
function watchFiles() {
watch(path.js, minifyJS);
watch(path.css, parallel(minifyCSS, copySourceCSS));
}
export const build = parallel(minifyJS, minifyCSS, copySourceCSS);
export default series(build, watchFiles);