From 7cc7297ea7dd4e83a637a906c02b2507d9a59dae Mon Sep 17 00:00:00 2001 From: Julien Huang Date: Mon, 22 May 2023 22:29:59 +0200 Subject: [PATCH] fix(nuxt): treeshake `` with webpack (#21013) Co-authored-by: Inesh Bose <56732164+ineshbose@users.noreply.github.com> --- packages/nuxt/src/core/plugins/dev-only.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/nuxt/src/core/plugins/dev-only.ts b/packages/nuxt/src/core/plugins/dev-only.ts index 0cd7a40f2b..9899e663ff 100644 --- a/packages/nuxt/src/core/plugins/dev-only.ts +++ b/packages/nuxt/src/core/plugins/dev-only.ts @@ -9,7 +9,7 @@ interface DevOnlyPluginOptions { sourcemap?: boolean } -export const DevOnlyPlugin = createUnplugin((options: DevOnlyPluginOptions) => { +export const DevOnlyPlugin = createUnplugin((options: DevOnlyPluginOptions, meta) => { const DEVONLY_COMP_RE = /<(?:dev-only|DevOnly)>[\s\S]*?<\/(?:dev-only|DevOnly)>/g return { @@ -20,7 +20,7 @@ export const DevOnlyPlugin = createUnplugin((options: DevOnlyPluginOptions) => { const { type } = parseQuery(search) // vue files - if (pathname.endsWith('.vue') && (type === 'template' || !search)) { + if (pathname.endsWith('.vue') && (meta.framework === 'webpack' || type === 'template' || !search)) { return true } },