Skip to content

Commit

Permalink
fix(plugin-vue): don't inline template when __VUE_PROD_DEVTOOLS__ (#81
Browse files Browse the repository at this point in the history
)

Co-authored-by: 三咲智子 Kevin Deng <sxzz@sxzz.moe>
  • Loading branch information
blakjak44 and sxzz authored May 30, 2024
1 parent 2848174 commit 277a3ab
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 4 deletions.
2 changes: 1 addition & 1 deletion packages/plugin-vue/src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ export async function transformMain(

// template
const hasTemplateImport =
descriptor.template && !isUseInlineTemplate(descriptor, !devServer)
descriptor.template && !isUseInlineTemplate(descriptor, options)

let templateCode = ''
let templateMap: RawSourceMap | undefined = undefined
Expand Down
11 changes: 8 additions & 3 deletions packages/plugin-vue/src/script.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,14 @@ export function setResolvedScript(
// inlined template cannot be individually hot updated.
export function isUseInlineTemplate(
descriptor: SFCDescriptor,
isProd: boolean,
options: ResolvedOptions,
): boolean {
return isProd && !!descriptor.scriptSetup && !descriptor.template?.src
return (
!options.devServer &&
!options.devToolsEnabled &&
!!descriptor.scriptSetup &&
!descriptor.template?.src
)
}

export const scriptIdentifier = `_sfc_main`
Expand All @@ -65,7 +70,7 @@ export function resolveScript(
...options.script,
id: descriptor.id,
isProd: options.isProduction,
inlineTemplate: isUseInlineTemplate(descriptor, !options.devServer),
inlineTemplate: isUseInlineTemplate(descriptor, options),
templateOptions: resolveTemplateCompilerOptions(descriptor, options, ssr),
sourceMap: options.sourceMap,
genDefaultAs: canInlineMain(descriptor, options)
Expand Down

0 comments on commit 277a3ab

Please sign in to comment.