-
Notifications
You must be signed in to change notification settings - Fork 1
/
gulpfile.js
47 lines (38 loc) · 1.16 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
'use strict';
/* eslint-disable @typescript-eslint/no-var-requires */
const { dest, series, src } = require('gulp');
const clean = require('gulp-clean');
const webpack = require('webpack');
const webpackStream = require('webpack-stream');
const { merge } = require('webpack-merge');
const webpackConfig = require('./webpack.config');
const webpackConfigProduction = webpackConfig.map((config) =>
merge(config, {
devtool: false,
mode: 'production',
watch: false,
}),
);
function cleaning(cb) {
['src/assets/**/*.js', 'src/assets/**/*.txt'].forEach((_path) => {
src(_path, { read: false }).pipe(clean());
});
cb();
}
function streamWebpack(config) {
if (typeof config.entry === 'object') {
src(config.entry[Object.keys(config.entry)[0]]).pipe(webpackStream(config, webpack)).pipe(dest(config.output.path));
} else {
src(config.entry).pipe(webpackStream(config, webpack)).pipe(dest(config.output.path));
}
}
function building(cb) {
webpackConfigProduction.forEach(streamWebpack);
cb();
}
function dev(cb) {
webpackConfig.forEach(streamWebpack);
cb();
}
exports.build = series(cleaning, building);
exports.default = series(cleaning, dev);