feat: webpack hook load all chunks
This commit is contained in:
parent
eaff7b123c
commit
f8221a0f50
1 changed files with 19 additions and 0 deletions
|
@ -122,4 +122,23 @@ export const webpackContext = new Promise<any>((resolve) => {
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
|
const PACK_ID_REG = /\+(\{.*?"\})\[\w\]\+/
|
||||||
|
|
||||||
|
export const loadAllPacks = () => {
|
||||||
|
return webpackContext.then((ctx) => {
|
||||||
|
try {
|
||||||
|
const fn = ctx.e.toString()
|
||||||
|
const packsData = fn.match(PACK_ID_REG)[1] as string
|
||||||
|
// eslint-disable-next-line no-new-func, @typescript-eslint/no-implied-eval
|
||||||
|
const packs = Function(`return (${packsData})`)() as { [id: string]: string }
|
||||||
|
|
||||||
|
Object.keys(packs).forEach((id) => {
|
||||||
|
ctx.e(id)
|
||||||
|
})
|
||||||
|
} catch (err) {
|
||||||
|
console.error(err)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
export default webpackHook
|
export default webpackHook
|
||||||
|
|
Loading…
Reference in a new issue