-
Notifications
You must be signed in to change notification settings - Fork 83
/
webpack.config.ts
43 lines (37 loc) · 979 Bytes
/
webpack.config.ts
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
import * as path from 'path';
import webpack from 'webpack';
import HtmlWebpackPlugin from 'html-webpack-plugin';
const isProduction = process.env.NODE_ENV === 'production';
const entry = path.resolve(__dirname, 'index.tsx');
const config: webpack.Configuration = {
mode: isProduction ? 'production' : 'development',
entry,
devtool: 'inline-source-map',
module: {
rules: [
{
test: /\.tsx?$/,
exclude: /node_modules/,
use: 'babel-loader',
},
],
},
resolve: {
extensions: ['.tsx', '.ts', '.js'],
},
plugins: [
new HtmlWebpackPlugin({
title: 'Zero Width Detection',
template: path.resolve(__dirname, 'public/index.html'),
}),
],
output: {
filename: 'bundle.js',
path: path.resolve(__dirname, 'dist'),
},
};
if (!isProduction) {
config.entry = ['webpack-hot-middleware/client', entry];
config.plugins?.push(new webpack.HotModuleReplacementPlugin());
}
export default config;