-
Notifications
You must be signed in to change notification settings - Fork 1
/
gulpfile.js
48 lines (41 loc) · 1.02 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
const {src, dest, watch, series} = require('gulp');
const autoprefix = require('gulp-autoprefixer');
const csso = require('gulp-csso');
const sync = require('browser-sync').create();
const del = require('del');
const webpack = require('webpack-stream');
const SRC_CSS_FILES = 'src/css/**.css';
const SRC_TS_FILES = './src/ts/**.ts';
const DIST_CSS_DIR = './dist/css/';
const DIST_JS_DIR = './dist/js/';
const js = () => {
return src(SRC_TS_FILES)
.pipe(webpack(
require('./webpack.config.js')
))
.pipe(dest(DIST_JS_DIR))
;
}
const css = () => {
return src(SRC_CSS_FILES)
.pipe(autoprefix({
overrideBrowserslist: ['last 2 versions']
}))
.pipe(csso())
.pipe(dest(DIST_CSS_DIR))
;
}
const clear = () => {
return del(DIST_CSS_DIR);
}
const build = series(clear, css, js);
const serve = () => {
sync.init({
server: './',
});
watch(SRC_CSS_FILES, series(css)).on('change', sync.reload);
watch(SRC_TS_FILES, series(js)).on('change', sync.reload);
}
module.exports = {
js, css, serve, build,
};