2025-04-14 10:57:27 +08:00
|
|
|
import { fileURLToPath, URL } from 'node:url'
|
|
|
|
|
|
|
|
|
|
import { defineConfig } from 'vite'
|
|
|
|
|
import vue from '@vitejs/plugin-vue'
|
|
|
|
|
import Components from 'unplugin-vue-components/vite';
|
|
|
|
|
import { AntDesignVueResolver } from 'unplugin-vue-components/resolvers';
|
|
|
|
|
|
|
|
|
|
// https://vite.dev/config/
|
|
|
|
|
export default defineConfig({
|
|
|
|
|
plugins: [
|
|
|
|
|
vue()
|
|
|
|
|
, Components({
|
|
|
|
|
resolvers: [AntDesignVueResolver({
|
|
|
|
|
importStyle: 'less',// 启用LESS主题定制
|
|
|
|
|
resolveIcons: true
|
|
|
|
|
})],
|
|
|
|
|
})
|
|
|
|
|
],
|
|
|
|
|
resolve: {
|
|
|
|
|
alias: {
|
|
|
|
|
'@': fileURLToPath(new URL('./src', import.meta.url))
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
base: './',
|
|
|
|
|
build: {
|
|
|
|
|
assetsDir: 'assets'
|
|
|
|
|
},
|
|
|
|
|
server: {
|
|
|
|
|
proxy: {
|
|
|
|
|
'^/operate/*': {
|
|
|
|
|
changeOrigin: true,
|
2025-04-16 09:18:28 +08:00
|
|
|
target: 'http://192.168.2.156:10010/',
|
2025-04-14 10:57:27 +08:00
|
|
|
rewrite: (path) => {
|
|
|
|
|
return path.replace(/^\/operate/, 'operate')
|
|
|
|
|
}
|
|
|
|
|
// ,bypass(req, res, options) {
|
|
|
|
|
// //@ts-ignore
|
|
|
|
|
// const proxyUrl = new URL(options.rewrite(req.url) || '',(options.target))?.href || '';
|
|
|
|
|
// console.log(proxyUrl);
|
|
|
|
|
// req.headers['x-req-proxyUrl'] = proxyUrl
|
|
|
|
|
// res.setHeader('x-res-proxyUrl',proxyUrl)
|
|
|
|
|
// }
|
|
|
|
|
},
|
|
|
|
|
'^/maintenance/*': {
|
|
|
|
|
changeOrigin: true,
|
2025-04-16 09:18:28 +08:00
|
|
|
target: 'http://192.168.2.156:10010/',
|
2025-04-14 10:57:27 +08:00
|
|
|
rewrite: (path) => {
|
|
|
|
|
return path.replace(/^\/maintenance/, 'maintenance')
|
|
|
|
|
}
|
|
|
|
|
// ,bypass(req, res, options) {
|
|
|
|
|
// //@ts-ignore
|
|
|
|
|
// const proxyUrl = new URL(options.rewrite(req.url) || '',(options.target))?.href || '';
|
|
|
|
|
// console.log(proxyUrl);
|
|
|
|
|
// req.headers['x-req-proxyUrl'] = proxyUrl
|
|
|
|
|
// res.setHeader('x-res-proxyUrl',proxyUrl)
|
|
|
|
|
// }
|
|
|
|
|
},
|
|
|
|
|
'^/user/*': {
|
|
|
|
|
changeOrigin: true,
|
2025-04-16 09:18:28 +08:00
|
|
|
target: 'http://192.168.2.156:10010/',
|
2025-04-14 10:57:27 +08:00
|
|
|
rewrite: (path) => {
|
|
|
|
|
return path.replace(/^\/user/, 'user')
|
|
|
|
|
}
|
|
|
|
|
// ,bypass(req, res, options) {
|
|
|
|
|
// //@ts-ignore
|
|
|
|
|
// const proxyUrl = new URL(options.rewrite(req.url) || '',(options.target))?.href || '';
|
|
|
|
|
// console.log(proxyUrl);
|
|
|
|
|
// req.headers['x-req-proxyUrl'] = proxyUrl
|
|
|
|
|
// res.setHeader('x-res-proxyUrl',proxyUrl)
|
|
|
|
|
// }
|
2025-04-17 18:31:22 +08:00
|
|
|
},
|
|
|
|
|
'^/order/*': {
|
|
|
|
|
changeOrigin: true,
|
|
|
|
|
target: 'http://192.168.2.156:10010/',
|
|
|
|
|
rewrite: (path) => {
|
|
|
|
|
return path.replace(/^\/order/, 'order')
|
|
|
|
|
}
|
|
|
|
|
// ,bypass(req, res, options) {
|
|
|
|
|
// //@ts-ignore
|
|
|
|
|
// const proxyUrl = new URL(options.rewrite(req.url) || '',(options.target))?.href || '';
|
|
|
|
|
// console.log(proxyUrl);
|
|
|
|
|
// req.headers['x-req-proxyUrl'] = proxyUrl
|
|
|
|
|
// res.setHeader('x-res-proxyUrl',proxyUrl)
|
|
|
|
|
// }
|
2025-04-14 10:57:27 +08:00
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
cors: true,
|
|
|
|
|
host: '0.0.0.0'
|
|
|
|
|
}
|
|
|
|
|
})
|