Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: only inject webpack hot client in webpack4 #986

Merged
merged 3 commits into from
Mar 31, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
## Changelog

## 3.8.14

- Fix: only inject webpack hot client in webpack4

## 3.8.13

- Fix: build-scripts version
Expand Down
4 changes: 4 additions & 0 deletions packages/plugin-rax-app/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# Changelog

## 7.0.8

- Fix: only inject webpack hot client in webpack4

## 7.0.7

- Fix: SPA title couldn't specified by route info
Expand Down
4 changes: 2 additions & 2 deletions packages/plugin-rax-app/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "build-plugin-rax-app",
"version": "7.0.7",
"version": "7.0.8",
"description": "The basic webpack configuration for rax project",
"author": "Rax Team",
"main": "lib/index.js",
Expand Down Expand Up @@ -52,4 +52,4 @@
"url": "[email protected]:raxjs/rax-app.git"
},
"gitHead": "07ac7bb07162aac8c90778dd1de4a2060f8df498"
}
}
6 changes: 4 additions & 2 deletions packages/plugin-rax-app/src/config/user.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,10 @@ const devServerDefaultOptionsMap = {
},
},
client: {
overlay: false,
logging: 'none',
overlay: {
errors: true,
warnings: false,
},
},
onBeforeSetupMiddleware({ app }) {
app.use((req, res, next) => {
Expand Down
8 changes: 6 additions & 2 deletions packages/plugin-rax-app/src/utils/injectHotReloadEntries.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,15 @@
import { isWebpack4 } from '@builder/compat-webpack4';

export default function (config) {
const entries = config.entryPoints.entries();
Object.keys(entries).forEach((entryName) => {
const entrySet = config.entry(entryName);
const entryFiles = entrySet.values();
const finalEntryFile = entryFiles[entryFiles.length - 1];
// Add webpack hot dev client
entrySet.prepend(require.resolve('react-dev-utils/webpackHotDevClient'));
// Add webpack hot dev client for webpack4
if (isWebpack4) {
entrySet.prepend(require.resolve('react-dev-utils/webpackHotDevClient'));
}
// Add module.hot.accept() to entry
entrySet.add(`${require.resolve('../Loaders/HmrLoader')}!${finalEntryFile}`);
entrySet.delete(finalEntryFile);
Expand Down
2 changes: 1 addition & 1 deletion packages/rax-app/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
"build-scripts": "^1.1.0",
"build-plugin-app-core": "2.1.0",
"build-plugin-ice-config": "2.0.2",
"build-plugin-rax-app": "7.0.7",
"build-plugin-rax-app": "7.0.8",
"build-plugin-rax-kraken": "2.1.1",
"build-plugin-rax-miniapp": "2.0.2",
"build-plugin-rax-pha": "2.0.3",
Expand Down