diff --git a/CHANGELOG.md b/CHANGELOG.md index 9e4ca4e4..3f9fe719 100644 --- a/CHANGELOG.md +++ b/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 diff --git a/packages/genesis-core/src/renderer.ts b/packages/genesis-core/src/renderer.ts index 1f1b7dc8..924cfd13 100644 --- a/packages/genesis-core/src/renderer.ts +++ b/packages/genesis-core/src/renderer.ts @@ -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; } } @@ -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(