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.

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