Skip to content

Commit

Permalink
HMR Preact
Browse files Browse the repository at this point in the history
  • Loading branch information
StopNGo committed Oct 14, 2024
1 parent 99e042c commit 05af7fe
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
2 changes: 2 additions & 0 deletions _webpack/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
},
"devDependencies": {
"@pmmmwh/react-refresh-webpack-plugin": "0.5.15",
"@prefresh/webpack": "4.0.1",
"@svgr/webpack": "8.1.0",
"@swc/core": "1.7.26",
"@testing-library/jest-dom": "6.5.0",
Expand All @@ -41,6 +42,7 @@
"@types/loadable__component": "5.13.9",
"@types/loadable__server": "5.12.11",
"@types/node": "22.7.5",
"@types/prefresh__webpack": "3.3.3",
"@types/react": "18.3.11",
"@types/react-dom": "18.3.0",
"@types/react-helmet": "6.1.11",
Expand Down
8 changes: 6 additions & 2 deletions _webpack/webpack/client.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import {
} from 'webpack'
import MiniCssExtractPlugin from 'mini-css-extract-plugin'
import ReactRefreshWebpackPlugin from '@pmmmwh/react-refresh-webpack-plugin'
import PreactRefreshPlugin from '@prefresh/webpack'
import LoadablePlugin from '@loadable/webpack-plugin'
import CssoWebpackPlugin from 'csso-webpack-plugin'
import ForkTsCheckerWebpackPlugin from 'fork-ts-checker-webpack-plugin'
Expand All @@ -16,7 +17,7 @@ import HtmlWebpackPlugin from 'html-webpack-plugin'
import CopyPlugin from 'copy-webpack-plugin'
import 'webpack-dev-server'

import { ALIAS, DEV_SERVER_PORT, DIST_DIR, IS_DEV, IS_LAZY_COMPILATION, SRC_DIR } from './constants'
import { ALIAS, DEV_SERVER_PORT, DIST_DIR, IS_DEV, IS_LAZY_COMPILATION, SRC_DIR, IS_PREACT } from './constants'
import * as Loaders from './loaders'

const withReport = Boolean(process.env.npm_config_withReport)
Expand Down Expand Up @@ -57,7 +58,10 @@ const plugins: WebpackPluginInstance[] = [
writeToDisk: true
}) as { apply: () => void },
...(IS_DEV
? [new HotModuleReplacementPlugin(), new ReactRefreshWebpackPlugin()]
? [
new HotModuleReplacementPlugin(),
IS_PREACT ? new PreactRefreshPlugin() : new ReactRefreshWebpackPlugin()
]
: [
new CssoWebpackPlugin(),
new BundleAnalyzerPlugin({
Expand Down

0 comments on commit 05af7fe

Please sign in to comment.