diff --git a/src/node/build/buildPluginEsbuild.ts b/src/node/build/buildPluginEsbuild.ts index 9671a79c3693f0..7b435428368dbd 100644 --- a/src/node/build/buildPluginEsbuild.ts +++ b/src/node/build/buildPluginEsbuild.ts @@ -1,5 +1,12 @@ +import fs from 'fs-extra' import { Plugin } from 'rollup' -import { tjsxRE, transform, resolveJsxOptions } from '../esbuildService' +import { + tjsxRE, + transform, + resolveJsxOptions, + vueJsxPublicPath, + vueJsxFilePath +} from '../esbuildService' import { SharedConfig } from '../config' export const createEsbuildPlugin = async ( @@ -11,6 +18,18 @@ export const createEsbuildPlugin = async ( return { name: 'vite:esbuild', + resolveId(id) { + if (id === vueJsxPublicPath) { + return vueJsxPublicPath + } + }, + + load(id) { + if (id === vueJsxPublicPath) { + return fs.readFileSync(vueJsxFilePath, 'utf-8') + } + }, + async transform(code, id) { const isVueTs = /\.vue\?/.test(id) && id.endsWith('lang=ts') if (tjsxRE.test(id) || isVueTs) {