diff --git a/packages/plugin-vue/src/main.ts b/packages/plugin-vue/src/main.ts index 44b1de74721efd..ba34f1ac31409a 100644 --- a/packages/plugin-vue/src/main.ts +++ b/packages/plugin-vue/src/main.ts @@ -268,7 +268,10 @@ async function genScriptCode( if (script) { // If the script is js/ts and has no external src, it can be directly placed // in the main module. - if ((!script.lang || script.lang === 'ts') && !script.src) { + if ( + (!script.lang || (script.lang === 'ts' && options.devServer)) && + !script.src + ) { scriptCode = options.compiler.rewriteDefault( script.content, '_sfc_main',