Skip to content

Commit e854b2f

Browse files
committed
Fixing Preact HMR in webpack
1 parent 99e042c commit e854b2f

File tree

4 files changed

+11
-5
lines changed

4 files changed

+11
-5
lines changed

_webpack/package.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "react-proto",
3-
"version": "2.0.0",
3+
"version": "2.0.1",
44
"description": "React TypeScript Boilerplate",
55
"author": "Max L Stop&Go",
66
"license": "ISC",
@@ -28,6 +28,7 @@
2828
},
2929
"devDependencies": {
3030
"@pmmmwh/react-refresh-webpack-plugin": "0.5.15",
31+
"@prefresh/webpack": "4.0.1",
3132
"@svgr/webpack": "8.1.0",
3233
"@swc/core": "1.7.26",
3334
"@testing-library/jest-dom": "6.5.0",
@@ -41,6 +42,7 @@
4142
"@types/loadable__component": "5.13.9",
4243
"@types/loadable__server": "5.12.11",
4344
"@types/node": "22.7.5",
45+
"@types/prefresh__webpack": "3.3.3",
4446
"@types/react": "18.3.11",
4547
"@types/react-dom": "18.3.0",
4648
"@types/react-helmet": "6.1.11",

_webpack/webpack/client.config.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import {
88
} from 'webpack'
99
import MiniCssExtractPlugin from 'mini-css-extract-plugin'
1010
import ReactRefreshWebpackPlugin from '@pmmmwh/react-refresh-webpack-plugin'
11+
import PreactRefreshPlugin from '@prefresh/webpack'
1112
import LoadablePlugin from '@loadable/webpack-plugin'
1213
import CssoWebpackPlugin from 'csso-webpack-plugin'
1314
import ForkTsCheckerWebpackPlugin from 'fork-ts-checker-webpack-plugin'
@@ -16,7 +17,7 @@ import HtmlWebpackPlugin from 'html-webpack-plugin'
1617
import CopyPlugin from 'copy-webpack-plugin'
1718
import 'webpack-dev-server'
1819

19-
import { ALIAS, DEV_SERVER_PORT, DIST_DIR, IS_DEV, IS_LAZY_COMPILATION, SRC_DIR } from './constants'
20+
import { ALIAS, DEV_SERVER_PORT, DIST_DIR, IS_DEV, IS_LAZY_COMPILATION, SRC_DIR, IS_PREACT } from './constants'
2021
import * as Loaders from './loaders'
2122

2223
const withReport = Boolean(process.env.npm_config_withReport)
@@ -57,7 +58,10 @@ const plugins: WebpackPluginInstance[] = [
5758
writeToDisk: true
5859
}) as { apply: () => void },
5960
...(IS_DEV
60-
? [new HotModuleReplacementPlugin(), new ReactRefreshWebpackPlugin()]
61+
? [
62+
new HotModuleReplacementPlugin(),
63+
IS_PREACT ? new PreactRefreshPlugin() : new ReactRefreshWebpackPlugin()
64+
]
6165
: [
6266
new CssoWebpackPlugin(),
6367
new BundleAnalyzerPlugin({

_webpack/webpack/constants.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import path from 'path'
22

33
const IS_DEV: boolean = String(process.env.NODE_ENV).trim() === 'development'
44

5-
const IS_PREACT: boolean = true
5+
const IS_PREACT: boolean = false
66
const IS_SWC: boolean = true
77
const IS_LAZY_COMPILATION = false
88
const DEV_SERVER_PORT: number = 8080

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "react-proto",
3-
"version": "2.0.0",
3+
"version": "2.0.1",
44
"description": "React TypeScript Boilerplate",
55
"author": "Max L Stop&Go",
66
"license": "ISC",

0 commit comments

Comments
 (0)