123456789101112131415161718192021222324252627282930313233343536373839404142434445 |
- import {fileURLToPath, URL} from 'node:url'
- import {defineConfig} from 'vite'
- import config from './src/config'
- import useVitePlugins from './vite-plugins'
- let prefixKeys = Object.keys(config).filter(i => i.includes('Prefix'))
- let proxyObj = prefixKeys.reduce((r, i) => {
- let prefix = config[i]
- r[prefix] = {
- target: config.proxyLocation + prefix,
- ws: true,
- changeOrigin: true,
- rewrite: path => path.replace(new RegExp('^' + prefix), ''),
- timeout: 10000000,
- }
- return r
- }, {})
- // https://vitejs.dev/config/
- export default defineConfig({
- base: './',
- plugins: useVitePlugins(),
- resolve: {
- alias: {
- '@': fileURLToPath(new URL('./src', import.meta.url)),
- }
- },
- css: {
- preprocessorOptions: {
- scss: {
- additionalData: `@use "@/assets/styles/element/index.scss" as *;`,
- },
- },
- },
- // 开发环境代理配置,请更换target为后端服务器地址
- server: {
- port: 5173,
- proxy: proxyObj,
- },
- build: {
- // 当生产环境浏览器版本较低时,请改为es2015
- target: 'modules'
- }
- })
|