-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathwebpack.config.js
75 lines (73 loc) · 2.1 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
const path = require('path');
const HtmlWebpackPlugin = require('html-webpack-plugin');
const StatsWebpackPlugin = require('stats-webpack-plugin');
const ReactRefreshWebpackPlugin = require('@pmmmwh/react-refresh-webpack-plugin');
const { version } = require('./package.json');
const childProcess = require('child_process');
const gitShaBuffer = childProcess.execSync('git rev-parse --short HEAD');
const gitSha = gitShaBuffer.toString().trim();
module.exports = (env) => {
const isDevMode = !!(env && env.dev);
return {
devServer: {
proxy: {
'/sandiego-2020-general-results': {
target: 'http://0.0.0.0:8081',
changeOrigin: true,
},
},
},
devtool: isDevMode ? 'eval-source-map' : 'source-map',
entry: ['fontsource-dm-mono/400.css', path.resolve(__dirname, 'src')],
mode: isDevMode ? 'development' : 'production',
module: {
rules: [
isDevMode && {
test: /\.tsx?$/,
include: path.resolve(__dirname, 'src'),
use: [
{
loader: require.resolve('babel-loader'),
options: {
plugins: [require.resolve('react-refresh/babel')],
},
},
],
},
{
test: /\.tsx?$/,
use: 'ts-loader',
include: path.resolve(__dirname, 'src'),
},
{
test: /\.css?$/,
use: ['style-loader', 'css-loader'],
},
{
test: /\.woff2?$/,
use: 'file-loader',
},
].filter(Boolean),
},
output: {
filename: '[id].[hash].js',
chunkFilename: '[id].[hash].js',
},
plugins: [
new HtmlWebpackPlugin({
releaseLabel: `${version} [${gitSha}:${isDevMode ? 'dev' : 'prod'}]`,
template: 'src/index.html',
title: 'SD Results',
}),
isDevMode &&
new ReactRefreshWebpackPlugin({
overlay: false,
}),
!isDevMode && new StatsWebpackPlugin('../stats.json'),
].filter(Boolean),
resolve: {
extensions: ['.js', '.ts', '.tsx'],
},
stats: 'minimal',
};
};