You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

60 lines
1.9 KiB

  1. import { Plugin as importToCDN } from "vite-plugin-cdn-import";
  2. /**
  3. * @description `cdn`使cdn模式 .env.production VITE_CDN true
  4. * cdnhttps://www.bootcdn.cn,当然你也可以选择 https://unpkg.com 或者 https://www.jsdelivr.com
  5. * 使jscss文件cdn
  6. */
  7. export const cdn = importToCDN({
  8. //(prodUrl解释: name: 对应下面modules的name,version: 自动读取本地package.json中dependencies依赖中对应包的版本号,path: 对应下面modules的path,当然也可写完整路径,会替换prodUrl)
  9. prodUrl: "https://cdn.bootcdn.net/ajax/libs/{name}/{version}/{path}",
  10. modules: [
  11. {
  12. name: "vue",
  13. var: "Vue",
  14. path: "vue.global.prod.min.js"
  15. },
  16. {
  17. name: "vue-router",
  18. var: "VueRouter",
  19. path: "vue-router.global.min.js"
  20. },
  21. {
  22. name: "vue-i18n",
  23. var: "VueI18n",
  24. path: "vue-i18n.runtime.global.prod.min.js"
  25. },
  26. // 项目中没有直接安装vue-demi,但是pinia用到了,所以需要在引入pinia前引入vue-demi(https://github.com/vuejs/pinia/blob/v2/packages/pinia/package.json#L77)
  27. {
  28. name: "vue-demi",
  29. var: "VueDemi",
  30. path: "index.iife.min.js"
  31. },
  32. {
  33. name: "pinia",
  34. var: "Pinia",
  35. path: "pinia.iife.min.js"
  36. },
  37. {
  38. name: "element-plus",
  39. var: "ElementPlus",
  40. path: "index.full.min.js",
  41. css: "index.min.css"
  42. },
  43. {
  44. name: "axios",
  45. var: "axios",
  46. path: "axios.min.js"
  47. },
  48. {
  49. name: "dayjs",
  50. var: "dayjs",
  51. path: "dayjs.min.js"
  52. },
  53. {
  54. name: "echarts",
  55. var: "echarts",
  56. path: "echarts.min.js"
  57. }
  58. ]
  59. });