| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475 |
- import { defineConfig } from "vite"
- import { fileURLToPath, URL } from "node:url"
- import vue from "@vitejs/plugin-vue"
- import AutoImport from "unplugin-auto-import/vite"
- import Components from "unplugin-vue-components/vite"
- import { ElementPlusResolver } from "unplugin-vue-components/resolvers"
- import path from "path"
- // https://vitejs.dev/config/
- export default defineConfig({
- plugins: [
- vue(),
- //引入vue 插件
- AutoImport({
- imports: ["vue"],
- //dts: "src/auto-import.d.ts",
- }),
- //plus按需引入
- AutoImport({
- resolvers: [ElementPlusResolver()],
- }),
- //plus按需引入
- Components({
- resolvers: [ElementPlusResolver()],
- }),
- ],
- resolve: {
- alias: {
- "vue-i18n": "vue-i18n/dist/vue-i18n.cjs.js",
- "@": fileURLToPath(new URL("./src", import.meta.url)),
- comp: fileURLToPath(new URL("./src/components", import.meta.url)),
- },
- },
- base: "/",
- build: {
- chunkSizeWarningLimit: 3000,
- minify: "terser", // 必须启用:terserOptions配置才会有效
- terserOptions: {
- compress: {
- // 生产环境时移除console.log调试代码
- drop_console: true,
- drop_debugger: true,
- },
- },
- rollupOptions: {
- output: {
- manualChunks(id) {
- // 将pinia的全局库实例打包进vendor,避免和页面一起打包造成资源重复引入
- if (id.includes(path.resolve(__dirname, "/src/store/index.ts"))) {
- return "vendor"
- }
- },
- },
- },
- },
- server: {
- //使用IP能访问
- host: "0.0.0.0",
- // 热更新
- hmr: true,
- //设为 true 时若端口已被占用则会直接退出,而不是尝试下一个可用端口
- strictPort: false,
- port: 8290,
- open: true,
- proxy: {
- // 接口地址代理
- "/api": {
- target: "http://shvber.com:8290", // 接口的域名
- secure: false, // 如果是https接口,需要配置这个参数
- changeOrigin: true, // 如果接口跨域,需要进行这个参数配置
- rewrite: (path) => path.replace(/^\/api/, "/api"),
- },
- },
- },
- })
|