fix(nuxt): treeshake <DevOnly> with webpack (#21013)

Co-authored-by: Inesh Bose <56732164+ineshbose@users.noreply.github.com>
This commit is contained in:
Julien Huang 2023-05-22 22:29:59 +02:00 committed by GitHub
parent c37ebab1ef
commit 7cc7297ea7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -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
}
},