Created
September 29, 2025 06:44
-
-
Save lhlyu/3abcee0e6a1d867fe9e80305628c0c97 to your computer and use it in GitHub Desktop.
vue cdn
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import vue from '@vitejs/plugin-vue' | |
| import { defineConfig } from 'vite' | |
| import importToCDN from 'vite-plugin-cdn-import' | |
| import AutoImport from 'unplugin-auto-import/vite' | |
| import { NaiveUiResolver } from 'unplugin-vue-components/resolvers' | |
| import Components from 'unplugin-vue-components/vite' | |
| // https://vite.dev/config/ | |
| export default defineConfig(({ mode }) => { | |
| return { | |
| plugins: [ | |
| vue(), | |
| AutoImport({ | |
| imports: ['vue', 'vue-router', '@vueuse/core', { | |
| 'naive-ui': [ | |
| 'useDialog', | |
| 'useMessage', | |
| 'useNotification', | |
| 'useLoadingBar', | |
| 'useThemeVars', | |
| ] | |
| }] | |
| }), | |
| Components({ | |
| resolvers: [NaiveUiResolver()] | |
| }), | |
| // 这个插件和`AutoImport`存在冲突,暂时无法解决 | |
| importToCDN({ | |
| modules: [ | |
| { | |
| name: 'vue', | |
| var: 'Vue', | |
| path: 'https://unpkg.com/vue/dist/vue.global.prod.js' | |
| }, | |
| { | |
| name: 'vue-demi', | |
| var: 'VueDemi', | |
| path: 'https://unpkg.com/vue-demi/lib/index.iife.js' | |
| }, | |
| { | |
| name: 'vue-router', | |
| var: 'VueRouter', | |
| path: 'https://unpkg.com/vue-router/dist/vue-router.global.prod.js' | |
| }, | |
| { | |
| name: 'pinia', | |
| var: 'Pinia', | |
| path: 'https://unpkg.com/pinia/dist/pinia.iife.prod.js' | |
| }, | |
| { | |
| name: '@vueuse/core', | |
| var: 'VueUse', | |
| path: 'https://unpkg.com/@vueuse/shared/index.iife.min.js' | |
| }, | |
| { | |
| name: '@vueuse/core', | |
| var: 'VueUse', | |
| path: 'https://unpkg.com/@vueuse/core/index.iife.min.js' | |
| }, | |
| // lucide-vue-next 存在bug,关注 https://github.com/lucide-icons/lucide/issues/3627 | |
| // { | |
| // name: 'lucide-vue-next', | |
| // var: 'LucideVueNext', | |
| // path: 'https://unpkg.com/lucide-vue-next/dist/umd/lucide-vue-next.min.js' | |
| // }, | |
| { | |
| name: 'naive-ui', | |
| var: 'naive', | |
| path: 'https://unpkg.com/naive-ui/dist/index.prod.js' | |
| }, | |
| { | |
| name: 'arco-design-color', | |
| var: 'ArcoDesignColor', | |
| path: 'https://unpkg.com/arco-design-color/dist/index.prod.iife.js' | |
| } | |
| ] | |
| }) | |
| ], | |
| } | |
| }) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment