xiaoju-survey/web/vite.config.ts

169 lines
4.1 KiB
TypeScript
Raw Normal View History

2024-05-09 12:34:24 +00:00
import { fileURLToPath, URL } from 'node:url'
import { defineConfig, normalizePath } from 'vite'
import vue from '@vitejs/plugin-vue'
import vueJsx from '@vitejs/plugin-vue-jsx'
2024-05-09 12:34:24 +00:00
import { createMpaPlugin, createPages } from 'vite-plugin-virtual-mpa'
2024-05-09 12:34:24 +00:00
import AutoImport from 'unplugin-auto-import/vite'
import Components from 'unplugin-vue-components/vite'
import Icons from 'unplugin-icons/vite'
import IconsResolver from 'unplugin-icons/resolver'
import { ElementPlusResolver } from 'unplugin-vue-components/resolvers'
import './report'
2024-05-09 12:34:24 +00:00
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.js'
},
{
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: () => normalizePath('/src/render/index.html')
},
{
from: /management\/preview/,
to: () => normalizePath('/src/render/index.html')
},
2024-05-09 12:34:24 +00:00
{
from: /\/|\/management\/.?/,
to: () => normalizePath('/src/management/index.html')
}
]
})
// https://vitejs.dev/config/
export default defineConfig({
optimizeDeps: {
include: [
'lodash-es',
'async-validator',
'vuedraggable',
'element-plus/es',
'@wangeditor/editor-for-vue',
'element-plus/es/components/*/style/index',
'element-plus/dist/locale/zh-cn.mjs',
'clipboard',
'qrcode',
'moment',
'moment/locale/zh-cn',
'echarts',
'nanoid',
'yup',
'crypto-js/sha256',
'element-plus/es/locale/lang/zh-cn',
'node-forge',
'@logicflow/core',
'@logicflow/extension'
2024-05-09 12:34:24 +00:00
]
},
plugins: [
vue(),
vueJsx(),
AutoImport({
resolvers: [
ElementPlusResolver(),
// Auto import icon components
IconsResolver({
prefix: 'Icon'
})
]
}),
Components({
resolvers: [
ElementPlusResolver({
importStyle: 'sass'
}),
// Auto register icon components
IconsResolver({
enabledCollections: ['ep']
})
]
}),
Icons({
autoInstall: true
}),
mpaPlugin
],
resolve: {
alias: {
'@': fileURLToPath(new URL('./src', import.meta.url)),
'@management': fileURLToPath(new URL('./src/management', import.meta.url)),
'@materials': fileURLToPath(new URL('./src/materials', import.meta.url)),
'@render': fileURLToPath(new URL('./src/render', import.meta.url))
}
},
appType: 'mpa',
css: {
preprocessorOptions: {
scss: {
api: 'modern-compiler',
2024-05-09 12:34:24 +00:00
additionalData: `@use "@/management/styles/element-variables.scss" as *;`
}
}
},
server: {
port: 8080,
proxy: {
'/api': {
target: 'http://127.0.0.1:3000',
【Feature】:北大实践课作业 (#424) * 【北大开源实践】增加数据导出功能 (#294) * feat:添加了一个文件数据导出的功能和相应前端页面 * fix lint * fix conflict --------- Co-authored-by: dayou <853094838@qq.com> * fix: components.d.ts文件ignore * feat: Update README_EN.md * feat: Update README.md * feat:新增预览功能 (#257) * feat:问卷预览功能 * feat:修复样式问题 * fix: 优化预览展示 * refactor: 重构vue3组合式API写法 (#265) * feat: 抽离题型枚举 (#272) * feat: 抽离题型枚举 * fix: 投放的链接加时间戳去掉ifream缓存 * feat: serve端的node engines * feat: 权限接口请求优化以及修复其他问题 (#290) * feat: c端路由改造 (#296) * 【北大开源实践】增加数据导出功能 (#294) * feat:添加了一个文件数据导出的功能和相应前端页面 * fix lint * fix conflict --------- Co-authored-by: dayou <853094838@qq.com> * fix: 删除components.d.ts文件 * 【北大开源实践】- 问卷断点续答 - 前端 (#282) * feat:增加断点续答功能 * feat:增加断点续答功能 * fix: 同步代码并且解决冲突 --------- Co-authored-by: dayou <853094838@qq.com> * fix: 删除components.d.ts文件最终 * 【北大开源实践】-选项限制 (#284) * format: 代码格式化 (#160) * feat: 选项限制 * fix: 同步代码并解决冲突 * fix conflict * fix conflict * fix lint * fix server lint --------- Co-authored-by: dayou <853094838@qq.com> Co-authored-by: XiaoYuan <2521510174@qq.com> * feat: 登录失效检测 & 协作冲突检测 (#287) Co-authored-by: Liuxinyi <liuxy0406@163.com> Co-authored-by: dayou <853094838@qq.com> * fix: peking分支同步develop并解决冲突 * fix: 修正颜色不统一 (#338) * fix: 修正颜色不统一 * fix: 删除server下的lock文件 * 编辑冲突检测 (#351) * perl: 选项配额优化 * fix: pinia改写 * feat: 完善北大课程相关的内容 * fix: 修复断点续答以及样式问题 (#420) * feat: 修改readme * [Feature]: 密码复杂度检测 (#407) * feat: 密码复杂度检测 * chore: 改为服务端校验 * feat: 优化展示 * fix:修复编辑页在不同element版本下表现不一致问题 (#406) * fix: 通过声明element最低版本来确定tab样式表现 * fix lint * feat(选项设置扩展):选择类题型增加选项排列配置 (#403) * build: add optimizeDeps packages * feat(选项设置扩展):选择类题型增加选项排列配置 * feat(选项设置扩展): 验收问题修复 --------- Co-authored-by: jiangchunfu <jiangchunfu@kaike.la> * fix: 删除多余内容 * feat: 优化登录窗口 * fix: 修复断点续答以及样式问题 fix: 修复选项引用验收bug fix: 修复断点续答问题 fix: 修复断点续答 fix: ignore fix: 修复投票题默认值 fix: 优化断点续答逻辑 fix: 选中图标适应高度 fix: 回退最大最小选择 fix: 修复断点续答 fix: 修复elswitch不更新问题 fix: 修复访问密码更新不生效问题 fix: 修复样式 fix: 修复多选题最大最小限制 fix: 优化断点续答问题 修复多选题命中最多选择后无法取消问题 fix: 修复服务端的富文本解析 fix: lint fix: min error fix: 修复最少最多选择 fix: 修复投票问卷的最少最多选择 fix: 兼容断点续答情况下选项配额为0的情况 fix: 兼容断点续答情况下选项配额为0的情况 fix: 兼容单选题的断点续答下的选项配额 fix: 修复添加选项问题 fix: 前端提示服务的配额已满 fix: 更新填写的过程中配额减少情况 --------- Co-authored-by: sudoooooo <zjbbabybaby@gmail.com> Co-authored-by: Stahsf <30379566+50431040@users.noreply.github.com> Co-authored-by: Jiangchunfu <mrj_kevin@163.com> Co-authored-by: jiangchunfu <jiangchunfu@kaike.la> * feat: 修改验收问题 (#421) * fix lint --------- Co-authored-by: Oseast <162945153+Oseast@users.noreply.github.com> Co-authored-by: sudoooooo <zjbbabybaby@gmail.com> Co-authored-by: chaorenluo <1243357953@qq.com> Co-authored-by: Realabiha <48506355+Realabiha@users.noreply.github.com> Co-authored-by: shiyiting763 <70299297+shiyiting763@users.noreply.github.com> Co-authored-by: yiyeah <68832436+yiyeah@users.noreply.github.com> Co-authored-by: XiaoYuan <2521510174@qq.com> Co-authored-by: Xinyi Liu <74805961+colmon46@users.noreply.github.com> Co-authored-by: Liuxinyi <liuxy0406@163.com> Co-authored-by: nil <wangweiguo2013@icloud.com> Co-authored-by: 王晓聪 <wang86976110@126.com> Co-authored-by: taoshuang <taoshuang@didiglobal.com> Co-authored-by: luch1994 <1097650398@qq.com> Co-authored-by: Stahsf <30379566+50431040@users.noreply.github.com> Co-authored-by: Jiangchunfu <mrj_kevin@163.com> Co-authored-by: jiangchunfu <jiangchunfu@kaike.la> Co-authored-by: luch <32321690+luch1994@users.noreply.github.com>
2024-09-12 14:10:18 +00:00
changeOrigin: true
},
'/exportfile': {
target: 'http://127.0.0.1:3000',
2024-05-09 12:34:24 +00:00
changeOrigin: true
},
// 静态文件的默认存储文件夹
'/userUpload': {
target: 'http://127.0.0.1:3000',
changeOrigin: true
2024-05-09 12:34:24 +00:00
}
}
},
build: {
rollupOptions: {
output: {
assetFileNames: '[ext]/[name]-[hash].[ext]',
chunkFileNames: 'js/[name]-[hash].js',
entryFileNames: 'js/[name]-[hash].js',
manualChunks(id) {
// 建议根据项目生产实际情况进行优化部分可走cdn或进行小资源包合并
if (id.includes('element-plus')) {
return 'element-plus'
}
if (id.includes('wangeditor')) {
return 'wangeditor'
}
if (id.includes('node-forg')) {
return 'node-forg'
}
if (id.includes('echarts')) {
return 'echarts'
}
if (id.includes('node_modules')) {
return 'packages'
}
}
}
}
2024-05-09 12:34:24 +00:00
}
})