-
Notifications
You must be signed in to change notification settings - Fork 1
/
webpack.config.js
78 lines (74 loc) · 1.85 KB
/
webpack.config.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
'use strict';
const path = require('path');
const webpack = require('webpack');
const findParam = require('./script/findEnv');
const ENV = JSON.stringify(findParam('ENV'));
const common_config = {
entry: ['./test/test.ts', './src/main.tsx'],
output: {
filename: 'js/bundle.js',
path: path.join(__dirname, 'bin'),
},
module: {
rules: [
{
test: /(.tsx|.ts|.jsx|.js)$/,
loader: 'ts-loader',
options: {
transpileOnly: true,
},
},
{
test: /(.glsl|.fs|.vs)$/,
loader: 'webpack-glsl-loader',
},
],
},
resolve: {
modules: [
path.resolve('./test'),
path.resolve('./libs'),
path.resolve('./library'),
path.resolve('./src'),
path.resolve('./node_modules'),
],
extensions: ['.tsx', '.ts', '.js', '.json'],
},
plugins: [new webpack.DefinePlugin({ ENV })],
};
const dev_config = {
devtool: 'eval-source-map',
stats: {
warnings: false,
},
watch: true,
devServer: {
clientLogLevel: 'silent',
host: '0.0.0.0',
contentBase: path.join(__dirname, 'bin'),
disableHostCheck: true,
port: '3000',
open: true,
openPage: 'http://localhost:3000',
},
};
const prod_config = {
entry: ['./src/main.tsx'],
};
const prod_ts_compile_option = {
sourceMap: false,
};
module.exports = (env, argv) => {
if (argv.mode === 'development') {
return {
...common_config,
...dev_config,
};
} else {
common_config.module.rules[0].options.compilerOptions = prod_ts_compile_option;
return {
...common_config,
...prod_config,
};
}
};