-
Notifications
You must be signed in to change notification settings - Fork 0
/
gulpfile.js
64 lines (57 loc) · 1.61 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
import gulp from "gulp";
import del from "del";
import webpackStream from "webpack-stream";
import webpack from "webpack";
let IS_DEV_MODE = false;
const SRC_DIR = "./src/";
const DEST_DIR = "./dist";
const ENV_CONFIG = {
"sandbox": {
},
"production": {
}
}
if (process.env.NODE_ENV !== 'production') {
console.log('***************');
console.log('Running in development mode');
console.log('***************');
IS_DEV_MODE = true;
}
gulp.task('clean', () => {
return del([
DEST_DIR + '/**/*',
]);
});
gulp.task('js', function () {
return gulp
.src([SRC_DIR + '/main.js'])
.pipe(webpackStream({
mode: IS_DEV_MODE ? "development" : "production",
devtool: IS_DEV_MODE ? 'source-map' : false,
module: {
rules: [
{
test: /\.tsx?$/,
use: 'ts-loader',
exclude: /node_modules/,
},
],
},
resolve: {
extensions: ['.tsx', '.ts', '.js'],
},
plugins: [
new webpack.DefinePlugin({
"JB_CONFIG": JSON.stringify(ENV_CONFIG[IS_DEV_MODE ? "sandbox" : "production"])
}),
]
}))
.pipe(gulp.dest(DEST_DIR));
});
gulp.task('assets', function () {
return gulp
.src([SRC_DIR + '/manifest.json', SRC_DIR + '/icon.svg'])
.pipe(gulp.dest(DEST_DIR));
});
gulp.task('build', gulp.series(['clean', 'js', 'assets']));
gulp.task('default', gulp.series(['build']));