Skip to content

Commit

Permalink
fix: 修复热更新报错 #71
Browse files Browse the repository at this point in the history
  • Loading branch information
lzxb committed Jul 7, 2022
1 parent 9ef7d0b commit 3371f1c
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 0 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
@@ -1,6 +1,7 @@
# CHANGELOG
- 2.1.7
- 升级Vue`2.7`
- 修复热更新报错的问题[#71](https://github.com/fmfe/genesis/issues/71)
- 2.1.6
- 移除`terser-webpack-plugin`
- 2.1.5
Expand Down
14 changes: 14 additions & 0 deletions packages/genesis-core/src/renderer.ts
Expand Up @@ -440,6 +440,10 @@ export class Renderer {
if (text) {
const clientManifest: Genesis.ClientManifest = JSON.parse(text);
clientManifest.publicPath = ssr.cdnPublicPath + ssr.publicPath;
if (!ssr.isProd) {
// fix https://github.com/fmfe/genesis/issues/71
removeHotUpdateFiles(clientManifest);
}
this.clientManifest = clientManifest;
}
}
Expand All @@ -454,6 +458,16 @@ export class Renderer {
}
}

function testHotUpdate(file: string) {
return !/\.hot-update.js(on)?$/.test(file);
}

function removeHotUpdateFiles(manifest: Genesis.ClientManifest) {
manifest.all = manifest.all.filter(testHotUpdate);
manifest.async = manifest.async.filter(testHotUpdate);
manifest.initial = manifest.initial.filter(testHotUpdate);
}

export function styleTagExtractCSS(value: string) {
let cssRules = '';
const newValue = value.replace(
Expand Down

0 comments on commit 3371f1c

Please sign in to comment.