xiaoju-survey/web/vite.config.ts
Weiguo Wang 6cd5fe892d
Feature/vue3 (#98)
* wip: vue3

* fix: dev时C端路由被B端router污染

* wip: debugger material

* wip: render widgets

* wip:回滚editOption

* c端抽离编辑态组件

* wip

* 事件调通

* wip

* feat: 可以正常提交

* fix: typo

* fix: 答题进度条

* fix: form 与 input 事件冲突

* 优化field管理

* 优化代码

* update

* 标题组件

* fix: 组件操作图标样式

---------

Co-authored-by: taoshaung <taoshaung@didiglobal.com>
2024-04-15 11:09:26 +08:00

74 lines
1.6 KiB
TypeScript

import { fileURLToPath, URL } from 'node:url'
import { defineConfig, normalizePath } from 'vite'
import vue from '@vitejs/plugin-vue'
import vueJsx from '@vitejs/plugin-vue-jsx'
import { createMpaPlugin, createPages } from 'vite-plugin-virtual-mpa'
import ElementPlus from 'unplugin-element-plus/vite'
const isProd = process.env.NODE_ENV === 'production'
const pages = createPages([
{
name: 'management',
filename: isProd ? 'management.html' : 'src/management/index.html',
template: 'src/management/index.html',
entry: '/src/management/main.ts'
},
{
name: 'render',
filename: isProd ? 'render.html' : 'src/render/index.html',
template: 'src/render/index.html',
entry: '/src/render/main.js'
}
])
const mpaPlugin = createMpaPlugin({
pages,
verbose: true,
rewrites: [
{
from: /render/,
to: (ctx) => normalizePath('/src/render/index.html')
},
{
from: /\/|\/management\/.?/,
to: (ctx) => normalizePath('/src/management/index.html')
},
]
})
// https://vitejs.dev/config/
export default defineConfig({
plugins: [
vue(),
vueJsx(),
ElementPlus({
useSource: true
}),
mpaPlugin
],
resolve: {
alias: {
'@': fileURLToPath(new URL('./src', import.meta.url))
}
},
css: {
preprocessorOptions: {
scss: {
additionalData: `@use "@/management/styles/variable.scss" as *;`
}
}
},
server: {
port: 8080,
proxy: {
'/api': {
target: 'http://127.0.0.1:3000',
changeOrigin: true
}
}
},
build: {
rollupOptions: {}
}
})