diff --git a/packages/nuxt/src/core/nuxt.ts b/packages/nuxt/src/core/nuxt.ts index cdfeb48d43d1..42345a814e7a 100644 --- a/packages/nuxt/src/core/nuxt.ts +++ b/packages/nuxt/src/core/nuxt.ts @@ -214,8 +214,7 @@ async function initNuxt (nuxt: Nuxt) { detectedComponents } - addVitePlugin(() => DetectComponentUsagePlugin.vite(componentDetectionConfig)) - addWebpackPlugin(() => DetectComponentUsagePlugin.webpack(componentDetectionConfig)) + addBuildPlugin(DetectComponentUsagePlugin(componentDetectionConfig)) nuxt.hook('app:templates', (app) => { // Skip first hook call diff --git a/packages/nuxt/src/core/plugins/detect-component-usage.ts b/packages/nuxt/src/core/plugins/detect-component-usage.ts index adca3f91fc08..d30c02862923 100644 --- a/packages/nuxt/src/core/plugins/detect-component-usage.ts +++ b/packages/nuxt/src/core/plugins/detect-component-usage.ts @@ -7,7 +7,7 @@ interface DetectComponentUsageOptions { detectedComponents: Set } -export const DetectComponentUsagePlugin = createUnplugin((options: DetectComponentUsageOptions) => { +export const DetectComponentUsagePlugin = (options: DetectComponentUsageOptions) => createUnplugin(() => { const importersToExclude = options?.exclude || [] const detectComponentUsagePatterns: Array<[importPattern: string | RegExp, name: string]> = [