Files
ojnext/rsbuild.config.ts
yuetsh 73884a075b
Some checks failed
Deploy / deploy (build, debian, 22, /root/OJDeploy/data/clientnext) (push) Has been cancelled
Deploy / deploy (build:staging, school, 8822, /root/OJ/data/dist) (push) Has been cancelled
fix again
2026-05-07 02:16:02 -06:00

107 lines
2.6 KiB
TypeScript
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
import path from "node:path"
import { defineConfig, loadEnv } from "@rsbuild/core"
import { pluginVue } from "@rsbuild/plugin-vue"
import AutoImport from "unplugin-auto-import/rspack"
import Components from "unplugin-vue-components/rspack"
import { NaiveUiResolver } from "unplugin-vue-components/resolvers"
const config: ReturnType<typeof defineConfig> = defineConfig(({ envMode }) => {
const { publicVars, rawPublicVars } = loadEnv({
cwd: process.cwd(),
mode: envMode,
})
const proxyConfig = {
target: rawPublicVars["PUBLIC_OJ_URL"],
changeOrigin: true,
}
const wsProxyConfig = {
target: rawPublicVars["PUBLIC_WS_URL"],
ws: true,
changeOrigin: true,
}
return {
plugins: [pluginVue()],
tools: {
rspack: {
plugins: [
AutoImport({
imports: [
"vue",
"vue-router",
"@vueuse/core",
"pinia",
{
"naive-ui": [
"useDialog",
"useMessage",
"useNotification",
"useLoadingBar",
],
},
{
from: "naive-ui",
imports: [
"DataTableColumn",
"FormRules",
"FormItemRule",
"SelectOption",
"UploadCustomRequestOptions",
"UploadFileInfo",
"MenuOption",
"DropdownDividerOption",
"DropdownOption",
],
type: true,
},
],
dts: "./src/auto-imports.d.ts",
}),
Components({
resolvers: [NaiveUiResolver()],
dts: "./src/components.d.ts",
}),
],
},
},
html: {
template: "./index.html",
},
source: {
entry: {
index: "./src/main.ts",
},
define: publicVars,
},
output: {
target: "web",
polyfill: "usage",
},
resolve: {
alias: {
utils: "./src/utils",
oj: "./src/oj",
admin: "./src/admin",
shared: "./src/shared",
// 强制 @wangeditor-next/editor 所有导入ESM/CJS走同一个文件
// 避免 Rspack v2 按 exports conditions 分别解析 .mjs/.js 产生双实例
"@wangeditor-next/editor$": path.resolve(
"./node_modules/@wangeditor-next/editor/dist/index.js"
),
},
},
server: {
port: 5173,
proxy: {
"/api": proxyConfig,
"/public": proxyConfig,
"/ws": wsProxyConfig,
},
},
}
})
export default config