- 添加 Naive UI 依赖到 package.json - 配置 Vite 开发服务器支持外部访问 (0.0.0.0:8080) - 配置 API 代理到后端 localhost:80,并正确处理 cookie 和 CSRF token - 修复 index.html 中 Jinja2 模板语法在开发模式下的问题 - 修改 get_context_for_dev 方法支持 GET 请求并返回 CSRF token - 修改前端使用 GET 请求获取初始数据,避免 CSRF token 验证问题
76 lines
1.6 KiB
TypeScript
76 lines
1.6 KiB
TypeScript
import path from 'path';
|
|
import { defineConfig } from 'vite';
|
|
import vue from '@vitejs/plugin-vue';
|
|
import vueJsx from '@vitejs/plugin-vue-jsx';
|
|
import jingrowui from 'jingrow-ui/vite';
|
|
import pluginRewriteAll from 'vite-plugin-rewrite-all';
|
|
import Components from 'unplugin-vue-components/vite';
|
|
import Icons from 'unplugin-icons/vite';
|
|
import IconsResolver from 'unplugin-icons/resolver';
|
|
import { sentryVitePlugin } from '@sentry/vite-plugin';
|
|
|
|
export default defineConfig({
|
|
plugins: [
|
|
vue(),
|
|
vueJsx(),
|
|
pluginRewriteAll(),
|
|
jingrowui(),
|
|
Components({
|
|
dirs: [
|
|
'src/components',
|
|
// 'src2/components',
|
|
'node_modules/jingrow-ui/src/components'
|
|
],
|
|
resolvers: [IconsResolver()]
|
|
}),
|
|
Icons(),
|
|
sentryVitePlugin({
|
|
url: process.env.SENTRY_URL,
|
|
org: process.env.SENTRY_ORG,
|
|
project: process.env.SENTRY_PROJECT,
|
|
applicationKey: 'jcloud-dashboard',
|
|
authToken: process.env.SENTRY_AUTH_TOKEN
|
|
})
|
|
],
|
|
resolve: {
|
|
alias: {
|
|
'@': path.resolve(__dirname, 'src')
|
|
}
|
|
},
|
|
optimizeDeps: {
|
|
include: ['feather-icons', 'showdown']
|
|
},
|
|
server: {
|
|
host: '0.0.0.0',
|
|
port: 8080,
|
|
proxy: {
|
|
'/api/action': {
|
|
target: 'http://localhost',
|
|
changeOrigin: true,
|
|
secure: false
|
|
}
|
|
}
|
|
},
|
|
build: {
|
|
outDir: '../jcloud/public/dashboard',
|
|
emptyOutDir: true,
|
|
sourcemap: true,
|
|
target: 'es2015',
|
|
rollupOptions: {
|
|
input: {
|
|
main: path.resolve(__dirname, 'index.html')
|
|
}
|
|
}
|
|
},
|
|
// @ts-ignore
|
|
test: {
|
|
globals: true,
|
|
environment: 'jsdom',
|
|
setupFiles: 'src/tests/setup/msw.js',
|
|
coverage: {
|
|
extension: ['.vue', '.js'],
|
|
all: true
|
|
}
|
|
}
|
|
});
|