hot reload

This commit is contained in:
Robin Appelman 2021-08-01 17:05:42 +02:00
commit eb629acd5b
8 changed files with 11978 additions and 4825 deletions

View file

@ -1,5 +1,9 @@
const CopyWebpackPlugin = require("copy-webpack-plugin");
const ReactRefreshWebpackPlugin = require('@pmmmwh/react-refresh-webpack-plugin');
const path = require('path');
const webpack = require('webpack');
const isDevelopment = process.env.NODE_ENV !== 'production';
module.exports = [{
entry: "./bootstrap.js",
@ -7,13 +11,27 @@ module.exports = [{
path: path.resolve(__dirname, "dist"),
filename: "bootstrap.js",
},
mode: "development",
mode: isDevelopment ? 'development' : 'production',
module: {
rules: [
{
test: /\.tsx?$/,
use: 'ts-loader',
test: /\.[jt]sx?$/,
exclude: /node_modules/,
use: [
{
loader: require.resolve('babel-loader'),
options: {
plugins: [
isDevelopment && require.resolve('react-refresh/babel'),
].filter(Boolean),
},
},
'ts-loader',
],
},
{
test: /\.css$/i,
use: ["style-loader", "css-loader", "postcss-loader"],
},
],
},
@ -21,8 +39,10 @@ module.exports = [{
extensions: ['.tsx', '.ts', '.js'],
},
plugins: [
new CopyWebpackPlugin({patterns: [{from: 'index.html'}]})
],
new CopyWebpackPlugin({patterns: [{from: 'index.html'}]}),
isDevelopment && new webpack.HotModuleReplacementPlugin(),
isDevelopment && new ReactRefreshWebpackPlugin(),
].filter(Boolean),
}, {
entry: "./src/worker.ts",
target: 'webworker',