import{PluginasimportToCDN}from"vite-plugin-cdn-import"exportdefaultdefineConfig({plugins:[vue(),visualizer({open:true,//注意这里要设置为true,否则无效filename:"stats.html",//分析图生成的文件名gzipSize:true,// 收集 gzip 大小并将其显示brotliSize:true,// 收集 brotli 大小并将其显示}),importToC...
首先在package.json中查看自己需要加速的依赖的版本号,如vue是3.2.45的: 进入bootcdn后,根据自己的版本号找到对应的CDN网址: 复制,然后将其粘贴到对应的path当中,如: importToCDN({modules:[{name:"vue",var:"Vue",path:"https://unpkg.com/vue@3/dist/vue.global.js",},],}), 当然要图简单的话,vit...
npm i vite-plugin-cdn-import-rely --save-dev Usage Example importimportFromCDNfrom"vite-plugin-cdn-import-rely";exportdefaultdefineConfig({plugins:[importFromCDN([{name:"element-plus",var:"ElementPlus",path:"index.full.min.js",relys:["vue"],},{name:"element-plus/es/locale/lang/zh-cn"...
// vite.config.jsimportcdnfrom'vite-plugin-cdn-import'exportdefault{plugins:[cdn({modules:['react','react-dom'],}),],} Preset packages react react-dom react-router-dom antd vue vue2 vue-router vue-router@3 moment dayjs axios lodash ...
Use preset // vite.config.jsimportcdnfrom'vite-plugin-cdn-import'exportdefault{plugins:[cdn({modules:['react','react-dom'],}),],} Preset packages react react-dom react-router-dom antd vue vue2 vue-router vue-router@3 moment dayjs ...
importvuefrom'@vitejs/plugin-vue'import{importToCDN,autoComplete}from'vite-plugin-cdn-import'exportdefault{plugins:[vue(),importToCDN({modules:[autoComplete('vue'),// vue2 use autoComplete('vue2')autoComplete('@vueuse/shared'),autoComplete('@vueuse/core')],}),],} ...
Installation npm: npm install vite-plugin-cdn-import-async--save-dev yarn: yarn add vite-plugin-cdn-import-async-D Usage Plugin config Specifyasyncordefertomodeparam whthin configs of the module you want to import asynchronously from CDN: ...
importvuefrom'@vitejs/plugin-vue'import{importToCDN,autoComplete}from'vite-plugin-cdn-import'exportdefault{plugins:[vue(),importToCDN({modules:[autoComplete('vue'),// vue2 use autoComplete('vue2')autoComplete('@vueuse/shared'),autoComplete('@vueuse/core')],}),],} ...
vue-router@3 moment dayjs axios lodash Options prodUrl Global prodUrl attribute, template url that generates CND file path. REF:prodUrl Type {prodUrl?:string} Default:https://cdn.jsdelivr.net/npm/{name}@{version}/{path} modules external config ...