mirror of
https://github.com/nuxt/nuxt.git
synced 2024-11-21 21:25:11 +00:00
fix(webpack): only insert dynamic require plugin when building
This commit is contained in:
parent
3fe427e620
commit
b619b35e9a
@ -34,24 +34,26 @@ export const bundle: NuxtBuilder['bundle'] = async (nuxt) => {
|
||||
}))
|
||||
|
||||
/** Inject rollup plugin for Nitro to handle dynamic imports from webpack chunks */
|
||||
const nitro = useNitro()
|
||||
const dynamicRequirePlugin = dynamicRequire({
|
||||
dir: resolve(nuxt.options.buildDir, 'dist/server'),
|
||||
inline:
|
||||
if (!nuxt.options.dev) {
|
||||
const nitro = useNitro()
|
||||
const dynamicRequirePlugin = dynamicRequire({
|
||||
dir: resolve(nuxt.options.buildDir, 'dist/server'),
|
||||
inline:
|
||||
nitro.options.node === false || nitro.options.inlineDynamicImports,
|
||||
ignore: [
|
||||
'client.manifest.mjs',
|
||||
'server.js',
|
||||
'server.cjs',
|
||||
'server.mjs',
|
||||
'server.manifest.mjs',
|
||||
],
|
||||
})
|
||||
const prerenderRollupPlugins = nitro.options._config.rollupConfig!.plugins as InputPluginOption[]
|
||||
const rollupPlugins = nitro.options.rollupConfig!.plugins as InputPluginOption[]
|
||||
ignore: [
|
||||
'client.manifest.mjs',
|
||||
'server.js',
|
||||
'server.cjs',
|
||||
'server.mjs',
|
||||
'server.manifest.mjs',
|
||||
],
|
||||
})
|
||||
const prerenderRollupPlugins = nitro.options._config.rollupConfig!.plugins as InputPluginOption[]
|
||||
const rollupPlugins = nitro.options.rollupConfig!.plugins as InputPluginOption[]
|
||||
|
||||
prerenderRollupPlugins.push(dynamicRequirePlugin)
|
||||
rollupPlugins.push(dynamicRequirePlugin)
|
||||
prerenderRollupPlugins.push(dynamicRequirePlugin)
|
||||
rollupPlugins.push(dynamicRequirePlugin)
|
||||
}
|
||||
|
||||
await nuxt.callHook(`${builder}:config`, webpackConfigs)
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user