1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24
| import { cdn } from "vite-plugin-cdn2"; import { SetupContext } from "vue"; import { SetupResult } from "vite-plugin-cdn2/resolve";
export function enableCDN(isEnabled: string) { if (isEnabled === "true") { return cdn({ resolve: { setup(ctx: SetupContext): SetupResult { const { name, version, relativeModule } = ctx.extra; console.log(JSON.stringify(ctx)); const url = `https://unpkg.com/${name}@${version}/${relativeModule}`; return { url, attrs: {} }; } }, modules: ["vue", "vue-demi", "pinia", "axios", "vant", "vue-router"] }); } }
|