-
Notifications
You must be signed in to change notification settings - Fork 568
/
webpack.config.js
51 lines (45 loc) · 1.29 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
const TerserPlugin = require('terser-webpack-plugin');
module.exports = {
entry: `${__dirname}/src/index.tsx`,
output: {
path: `${__dirname}/build`,
publicPath: '/build/',
filename: 'bundle.js',
},
// generate different source maps for dev and production
devtool: process.argv.indexOf('-p') === -1 ? 'eval-source-map' : 'source-map',
resolve: {
extensions: ['.ts', '.tsx', '.js'],
},
module: {
rules: [
// use ts-loader for ts and js files so all files are converted to es5
{ test: /\.(tsx?|js)$/, exclude: /node_modules/, loader: 'ts-loader' },
{ test: /\.js$/, loader: 'source-map-loader' },
],
},
// required because the defaults for webpack -p don't remove multiline comments
optimization:
process.argv.indexOf('-p') === -1
? {}
: {
minimize: true,
minimizer: [
new TerserPlugin({
terserOptions: {
output: {
comments: false,
},
},
extractComments: false,
}),
],
},
// to mimic GitHub Pages serving 404.html for all paths
// and test spa-github-pages redirect in dev
devServer: {
historyApiFallback: {
rewrites: [{ from: /\//, to: '/404.html' }],
},
},
};