Repository navigation
Expand file tree
/
Copy pathwebpack.config.js
More file actions
61 lines (58 loc) · 1.48 KB
/
Copy pathwebpack.config.js
File metadata and controls
61 lines (58 loc) · 1.48 KB
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
import path from 'path';
import { fileURLToPath } from 'url';
import webpack from 'webpack';
import CopyPlugin from 'copy-webpack-plugin';
const root = path.dirname(fileURLToPath(import.meta.url));
const src = path.join(root, 'src');
export default (_env, argv) => {
const production = argv.mode === 'production';
return {
mode: production ? 'production' : 'development',
devtool: production ? false : 'eval-source-map',
entry: ['core-js/stable', './src/client/index.tsx'],
output: {
path: path.join(root, 'dist'),
filename: 'static/js/index.js',
clean: true
},
devServer: {
static: './dist',
host: '127.0.0.1',
port: 4000
},
experiments: {
asyncWebAssembly: true
},
module: {
rules: [
{ test: /\.tsx?$/, use: 'ts-loader', exclude: /node_modules/ },
{ test: /\.mst$/, use: 'raw-loader' },
{ test: /\.m?js$/, resolve: { fullySpecified: false } }
]
},
resolve: {
extensions: ['.tsx', '.ts', '.js'],
alias: {
api: path.join(src, 'api'),
client: path.join(src, 'client'),
TypedObserver: path.join(src, 'client/TypedObserver')
}
},
plugins: [
new webpack.DefinePlugin({
'process.env.NODE_ENV': JSON.stringify(production ? 'production' : 'development'),
PROFILER: JSON.stringify(!production),
DEBUG: JSON.stringify(!production)
}),
new CopyPlugin({
patterns: [{ from: 'src/client/resources', to: '' }]
})
],
optimization: {
minimize: production
},
performance: {
hints: false
}
};
};