1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84
| // vite.config.js
import { defineConfig } from "vite"; import vue from "@vitejs/plugin-vue"; import vueJsx from "@vitejs/plugin-vue-jsx"; // import styleImport from "vite-plugin-style-import"; import commonjs from "rollup-plugin-commonjs"; import externalGlobals from "rollup-plugin-external-globals"; const { resolve } = require("path"); // https://vitejs.dev/config/ export default defineConfig({ base: "./", root: "./", resolve: { alias: { "@": resolve(__dirname, "./src/"), }, }, build: { rollupOptions: { external: ["vue", '@arco-design/web-vue', '@arco-design/web-vue/es/icon', 'axios', 'vue-router','vuex','dayjs'], plugins: [ commonjs(), externalGlobals({ vue: "Vue", vuex: "Vuex", axios: "axios", dayjs: "dayjs", "vue-router": "VueRouter", "@arco-design/web-vue": 'ArcoVue', "@arco-design/web-vue/es/icon": 'ArcoVueIcon', }), ], }, }, plugins: [ vue(), vueJsx({ // options are passed on to @vue/babel-plugin-jsx }),
// styleImport({ // libs: [ // { // libraryName: "element-plus", // esModule: true, // resolveStyle: (name) => { // return `element-plus/lib/theme-chalk/${name}.css`; // }, // resolveComponent: (name) => { // return `element-plus/lib/${name}`; // }, // }, // ], // }), ], });
// index.html
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8" /> <link rel="icon" href="/favicon.ico" /> <meta name="viewport" content="width=device-width, initial-scale=1.0" /> <script src="https://cdn.jsdelivr.net/npm/vue@3.2.20/dist/vue.global.min.js"></script> <script src="https://unpkg.com/@arco-design/web-vue@2.0.2/dist/arco-vue.min.js"></script> <script src="https://unpkg.com/@arco-design/web-vue@2.0.2/dist/arco-vue-icon.min.js"></script> <script src="https://cdn.jsdelivr.net/npm/vue-router@4.0.12/dist/vue-router.global.min.js"></script> <script src="https://cdn.jsdelivr.net/npm/vuex@4.0.2/dist/vuex.global.min.js"></script> <script src="https://cdn.jsdelivr.net/npm/axios@0.24.0/dist/axios.min.js"></script> <script src="https://cdn.bootcdn.net/ajax/libs/dayjs/1.4.1/dayjs.min.js"></script> <link rel="stylesheet" href="https://unpkg.com/@arco-design/web-vue@2.0.2/dist/arco.min.css"> <title>Vite App</title> </head> <body> <div id="app"></div> <script type="module" src="/src/main.js"></script> </body> </html>
|