import { fileURLToPath, URL } from 'node:url' import { defineConfig } from 'vite' import vue from '@vitejs/plugin-vue' import vueJsx from '@vitejs/plugin-vue-jsx' import path from 'node:path' import viteConfitExtend from "./vite.config.extend"; import Components from 'unplugin-vue-components/vite'; import { VantResolver } from 'unplugin-vue-components/resolvers'; // https://vitejs.dev/config/ export default defineConfig({ plugins: [ vue(), vueJsx(), Components({ resolvers: [VantResolver()], }), viteConfitExtend({ indexPath: '../app/index/view/web/vr.html', }), ], resolve: { alias: { '@': fileURLToPath(new URL('./src', import.meta.url)) } }, build: { target: 'modules', // cssCodeSplit: true,//启用/禁用 CSS 代码拆分 如果设置为false,整个项目中的所有 CSS 将被提取到一个 CSS 文件中 //指定输出路径 outDir: "../../public/", //生成静态资源的存放路径 assetsDir: "assets", //小于此阈值的导入或引用资源将内联为 base64 编码,以避免额外的 http 请求。设置为 0 可以完全禁用此项 assetsInlineLimit: 40960,//40kb //构建后是否生成 source map 文件 sourcemap: false, emptyOutDir: false, terserOptions: { output: { // 去掉注释内容 comments: true, }, }, rollupOptions: { externals: { 'axios': 'axios' }, output: { assetFileNames: `assets/[name].[hash].[ext]`, }, }, }, server: { cors: true, proxy: { '/mobile': { // 匹配请求路径,localhost:3000/snow target: 'http://h5.zqxg.cc/mobile', // 代理的目标地址 changeOrigin: true, // 开发模式,默认的origin是真实的 origin:localhost:3000 代理服务会把origin修改为目标地址 // secure: true, // 是否https接口 // ws: true, // 是否代理websockets // rewrite target目标地址 + '/abc',如果接口是这样的,那么不用重写 rewrite: (path) => path.replace(/^\/mobile/, '') // 路径重写,本项目不需要重写 // pathRewrite:{ // "^vr":"/vr" // }, } } } })