perf(nuxt): don't run island transform plugin if disabled (#21844)

This commit is contained in:
Julien Huang 2023-06-28 18:44:43 +02:00 committed by GitHub
parent 17801d3ae8
commit cc4cf68ed4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -222,9 +222,11 @@ export default defineNuxtModule<ComponentsOptions>({
experimentalComponentIslands: nuxt.options.experimental.componentIslands
}))
config.plugins.push(islandsTransform.vite({
getComponents
}))
if (isServer && nuxt.options.experimental.componentIslands) {
config.plugins.push(islandsTransform.vite({
getComponents
}))
}
})
nuxt.hook('webpack:config', (configs) => {
configs.forEach((config) => {
@ -248,9 +250,11 @@ export default defineNuxtModule<ComponentsOptions>({
experimentalComponentIslands: nuxt.options.experimental.componentIslands
}))
config.plugins.push(islandsTransform.webpack({
getComponents
}))
if (nuxt.options.experimental.componentIslands && mode === 'server') {
config.plugins.push(islandsTransform.webpack({
getComponents
}))
}
})
})
}