Skip to content

Commit b619b35

Browse files
committed
fix(webpack): only insert dynamic require plugin when building
1 parent 3fe427e commit b619b35

File tree

1 file changed

+18
-16
lines changed

1 file changed

+18
-16
lines changed

packages/webpack/src/webpack.ts

Lines changed: 18 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -34,24 +34,26 @@ export const bundle: NuxtBuilder['bundle'] = async (nuxt) => {
3434
}))
3535

3636
/** Inject rollup plugin for Nitro to handle dynamic imports from webpack chunks */
37-
const nitro = useNitro()
38-
const dynamicRequirePlugin = dynamicRequire({
39-
dir: resolve(nuxt.options.buildDir, 'dist/server'),
40-
inline:
37+
if (!nuxt.options.dev) {
38+
const nitro = useNitro()
39+
const dynamicRequirePlugin = dynamicRequire({
40+
dir: resolve(nuxt.options.buildDir, 'dist/server'),
41+
inline:
4142
nitro.options.node === false || nitro.options.inlineDynamicImports,
42-
ignore: [
43-
'client.manifest.mjs',
44-
'server.js',
45-
'server.cjs',
46-
'server.mjs',
47-
'server.manifest.mjs',
48-
],
49-
})
50-
const prerenderRollupPlugins = nitro.options._config.rollupConfig!.plugins as InputPluginOption[]
51-
const rollupPlugins = nitro.options.rollupConfig!.plugins as InputPluginOption[]
43+
ignore: [
44+
'client.manifest.mjs',
45+
'server.js',
46+
'server.cjs',
47+
'server.mjs',
48+
'server.manifest.mjs',
49+
],
50+
})
51+
const prerenderRollupPlugins = nitro.options._config.rollupConfig!.plugins as InputPluginOption[]
52+
const rollupPlugins = nitro.options.rollupConfig!.plugins as InputPluginOption[]
5253

53-
prerenderRollupPlugins.push(dynamicRequirePlugin)
54-
rollupPlugins.push(dynamicRequirePlugin)
54+
prerenderRollupPlugins.push(dynamicRequirePlugin)
55+
rollupPlugins.push(dynamicRequirePlugin)
56+
}
5557

5658
await nuxt.callHook(`${builder}:config`, webpackConfigs)
5759

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy