1. 安装插件
    2. npm install vite-plugin-cdn-import --save-dev
    1. 导入
    2. import importToCDN from "vite-plugin-cdn-import";
    3. 配置(以element-plus为例)
    4. plugins: [
    5. ...
    6. importToCDN({
    7. modules: [
    8. {
    9. name: "vue",
    10. var: "Vue",
    11. path: `https://unpkg.com/vue@next`,
    12. },
    13. {
    14. name: "element-plus",
    15. var: "ElementPlus",
    16. path: `https://unpkg.com/element-plus`,
    17. css: `https://unpkg.com/element-plus/dist/index.css`,
    18. },
    19. ],
    20. }),
    21. ],

    打包前后大小对比
    image.png
    image.png