diff --git a/packages/uni-app-vite/src/nvue/index.ts b/packages/uni-app-vite/src/nvue/index.ts index c0d42da8ba3b5b9e96a50de0c241a44a0be8ccfa..72fa552eed9c68ee2857e416cde5f25426d4a91f 100644 --- a/packages/uni-app-vite/src/nvue/index.ts +++ b/packages/uni-app-vite/src/nvue/index.ts @@ -14,6 +14,7 @@ import { uniAppCssPlugin } from './plugins/appCss' import { uniEsbuildPlugin } from './plugins/esbuild' import { uniMainJsPlugin } from './plugins/mainJs' import { uniPagesJsonPlugin } from './plugins/pagesJson' +import { uniRenderjsPlugin } from './plugins/renderjs' export { initNVueNodeTransforms } from './plugin' @@ -28,6 +29,7 @@ export function initNVuePlugins() { uniManifestJsonPlugin(), uniPagesJsonPlugin({ renderer, appService }), uniViteInjectPlugin('uni:app-inject', initAppProvide()), + uniRenderjsPlugin(), uniAppNVuePlugin({ appService }), uniEsbuildPlugin({ renderer, appService }), ...(appService ? [uniStatsPlugin(), uniTemplatePlugin({ renderer })] : []), diff --git a/packages/uni-app-vite/src/nvue/plugins/renderjs.ts b/packages/uni-app-vite/src/nvue/plugins/renderjs.ts new file mode 100644 index 0000000000000000000000000000000000000000..e62e372bbeb86dc8fb5ba0c1ee996306ea0da4db --- /dev/null +++ b/packages/uni-app-vite/src/nvue/plugins/renderjs.ts @@ -0,0 +1,19 @@ +import { Plugin } from 'vite' + +import { parseRenderjs } from '@dcloudio/uni-cli-shared' + +export function uniRenderjsPlugin(): Plugin { + return { + name: 'uni:app-nvue-renderjs', + async transform(code, id) { + const { type } = parseRenderjs(id) + if (!type) { + return + } + return { + code: `export default {}`, + map: { mappings: '' }, + } + }, + } +}