MISC: Fix support of react-refresh-webpack-plugin (#1392)

This commit is contained in:
catloversg 2024-06-13 04:31:13 +07:00 committed by GitHub
parent e76e254c3e
commit 2198a02152
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

@ -10,7 +10,7 @@ module.exports = (env, argv) => {
const isDevServer = (env || {}).devServer === true; const isDevServer = (env || {}).devServer === true;
const runInContainer = (env || {}).runInContainer === true; const runInContainer = (env || {}).runInContainer === true;
const isDevelopment = argv.mode === "development"; const isDevelopment = argv.mode === "development";
const isFastRefresh = argv.fast === "true"; const enableReactRefresh = (env || {}).enableReactRefresh === true;
const outputDirectory = "dist"; const outputDirectory = "dist";
const entry = "./src/index.tsx"; const entry = "./src/index.tsx";
@ -126,7 +126,7 @@ module.exports = (env, argv) => {
columns: true, columns: true,
module: true, module: true,
}), }),
isFastRefresh && new ReactRefreshWebpackPlugin(), enableReactRefresh && new ReactRefreshWebpackPlugin(),
].filter(Boolean), ].filter(Boolean),
target: "web", target: "web",
entry: entry, entry: entry,
@ -143,7 +143,7 @@ module.exports = (env, argv) => {
use: { use: {
loader: "babel-loader", loader: "babel-loader",
options: { options: {
plugins: [isFastRefresh && require.resolve("react-refresh/babel")].filter(Boolean), plugins: [enableReactRefresh && require.resolve("react-refresh/babel")].filter(Boolean),
cacheDirectory: true, cacheDirectory: true,
}, },
}, },