-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathwebpack.config.js
79 lines (78 loc) · 2.19 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
const path = require('path');
const HtmlWebpackPlugin = require('html-webpack-plugin');
const webpack = require('webpack');
const pkg = require('./package.json');
module.exports = (env) => {
const { production } = env;
const mode = production ? 'production' : 'development';
const dev = !production;
const homepage = production ? new URL(pkg.homepage).pathname : '/';
return {
mode,
devtool: dev && 'eval-source-map',
devServer: {
static: path.join(__dirname, 'examples/testsuite/'),
host: '0.0.0.0',
headers: {
// this works around getting net::ERR_CONTENT_LENGTH_MISMATCH 200 (OK)
// with webpack running inside a vs code dev container.
// Poking at things in the dark here but I presume it's
// related to keep alives. :)
// connection: 'close',
},
},
entry: {
testsuite: './examples/testsuite/index.ts',
react: './examples/react/index.tsx',
},
// optimization: {
// mangleExports: 'size',
// moduleIds: 'size',
// },
output: {
path: path.resolve(__dirname, 'public'),
filename: 'static/[name]-[contenthash].js',
assetModuleFilename: 'static/[name]-[hash][ext][query]',
publicPath: homepage,
},
plugins: [
new HtmlWebpackPlugin({
title: 'Dont-crop Test Suite',
chunks: ['testsuite'],
template: 'examples/testsuite/index.html',
filename: 'index.html',
inject: false,
}),
new HtmlWebpackPlugin({
title: 'Dont-Crop Test Suite',
chunks: ['react'],
filename: 'react.html',
}),
production && new webpack.optimize.LimitChunkCountPlugin({
maxChunks: 1,
}),
].filter((x) => !!x),
module: {
rules: [
{
test: /\.tsx?$/,
loader: 'ts-loader',
exclude: /node_modules/,
options: { configFile: 'tsconfig.json' },
},
{
test: /\.css$/,
use: ['style-loader', 'css-loader'],
sideEffects: true,
},
{
test: /\.(jpg|png)$/,
type: 'asset/resource',
},
],
},
resolve: {
extensions: ['.tsx', '.ts', '.js'],
},
};
};