-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathwebpack.config.js
97 lines (95 loc) · 2.37 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
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
const path = require('path');
const TerserPlugin = require('terser-webpack-plugin');
const nodeExternals = require('webpack-node-externals');
const { transform } = require('@formatjs/ts-transformer');
const isProduction = /^prod/.test(process.env.NODE_ENV);
const mode = isProduction ? 'production' : 'development';
module.exports = [
{
entry: path.join(__dirname, 'src', 'backend', 'index.ts'),
mode,
target: 'node',
externals: [nodeExternals()],
output: {
path: path.resolve(__dirname, 'lib'),
filename: 'index.js',
},
optimization: {
minimize: isProduction,
},
resolve: {
extensions: ['.ts', '.js'],
},
module: {
rules: [
{
test: /\.ts$/,
exclude: /node_modules/,
loader: 'ts-loader',
options: {
configFile: path.resolve(__dirname, 'tsconfig.backend.json'),
},
},
],
},
},
{
entry: path.join(__dirname, 'src', 'frontend', 'index.tsx'),
mode,
output: {
path: path.resolve(__dirname, 'public', 'static'),
filename: 'bundle.js',
chunkFilename: '[name].[contenthash:8].chunk.js',
publicPath: '/',
globalObject: 'this',
},
optimization: {
minimize: isProduction,
minimizer: [
new TerserPlugin({
terserOptions: {
parse: { ecma: 8 },
compress: {
ecma: 5,
warnings: false,
comparisons: false,
inline: 2,
},
mangle: { safari10: true },
keep_classnames: isProduction,
keep_fnames: isProduction,
output: {
ecma: 5,
comments: false,
ascii_only: true,
},
},
}),
],
},
resolve: {
extensions: ['.ts', '.tsx', '.js'],
},
module: {
rules: [
{
test: /\.tsx?$/,
exclude: /node_modules/,
loader: 'ts-loader',
options: {
configFile: path.resolve(__dirname, 'tsconfig.frontend.json'),
getCustomTransformers() {
return {
before: [
transform({
overrideIdFn: '[sha512:contenthash:base64:6]',
}),
],
};
},
},
},
],
},
},
];