-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathwebpack.config.js
44 lines (41 loc) · 1.07 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
const CompressionPlugin = require('compression-webpack-plugin');
const path = require('path');
const dir = path.resolve(__dirname);
const inDevelopment = !process.env.PRODUCTION;
// const BundleAnalyzerPlugin = require('webpack-bundle-analyzer').BundleAnalyzerPlugin;
const exp = {
mode: inDevelopment ? 'development' : 'production',
devtool: inDevelopment ? 'inline-source-map' : 'hidden-source-map',
entry: dir + '/src/client/index.tsx',
output: {
filename: 'bundle.js',
path: dir + '/src/static/build',
},
module: {
rules: [
{
test: /\.tsx?$/i,
exclude: /node_modules/,
use: { loader: 'ts-loader' },
},
{
test: /\.css$/i,
use: ['style-loader', 'css-loader'],
},
],
},
resolve: {
extensions: ['.tsx', '.ts', '.js', '.jsx', '.css'],
},
plugins: [new CompressionPlugin()],
};
if (inDevelopment) {
/* Uncomment this to enable the bundle analyzer server at localhost:8888
exp.plugins.push(
new BundleAnalyzerPlugin({
openAnalyzer: false
})
)
*/
}
module.exports = exp;