diff --git a/packages/plugin-vue/src/main.ts b/packages/plugin-vue/src/main.ts index 2f1288bf..e9577605 100644 --- a/packages/plugin-vue/src/main.ts +++ b/packages/plugin-vue/src/main.ts @@ -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 diff --git a/packages/plugin-vue/src/script.ts b/packages/plugin-vue/src/script.ts index 5c3ffd3e..1583c03a 100644 --- a/packages/plugin-vue/src/script.ts +++ b/packages/plugin-vue/src/script.ts @@ -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` @@ -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)