Open pxcoder opened 2 years ago
package.json
"dependencies": { "vant": "^3.4.5", "vue": "^3.2.25", }
src/plugins/vant.ts
import Vant from "vant"; export { Vant };
src/main.ts
import { createApp } from 'vue'; import App from './App.vue'; import { Vant } from '@/plugins/vant'; createApp(App).use(Vant).mount('#app');
vite.config.ts
import { defineConfig } from 'vite'; import vue from '@vitejs/plugin-vue'; import { viteExternalsPlugin } from 'vite-plugin-externals'; export default defineConfig(async ({ mode }) => { return { plugins: [ vue(), mode === 'production' ? viteExternalsPlugin({ vue: 'Vue', vant: 'vant', }) : undefined, ], }, }; });
此时 vant 是没有被替换的。
你好,我这里没有复现到你说的情况。我按照提供的参数,把example/vite2.7改成了你上面所说的配置,打包出来文件里面的vant是已经被替换的。
你可以提供一个最小复现的仓库吗?感谢~
package.json
src/plugins/vant.ts
src/main.ts
vite.config.ts
此时 vant 是没有被替换的。