1 Star 0 Fork 200

LUJINFENG/react-ant-admin

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
vite.config.ts 1.94 KB
一键复制 编辑 原始数据 按行查看 历史
孔乙己拉夫米 提交于 2023-11-16 13:36 . 菜单数据结构调整
import { defineConfig } from 'vite'
import react from '@vitejs/plugin-react'
import ReactRouterGenerator from "vite-plugin-react-router-generator"
import { resolve } from "path"
import { theme } from 'antd';
import lessToJs from 'less-vars-to-js';
import { readFileSync } from 'fs'
const { defaultAlgorithm, defaultSeed } = theme;
const varLessPath = "./theme/var.less"
const mapToken = defaultAlgorithm(defaultSeed);
const varLessStr = readFileSync(varLessPath, 'utf-8')
const customVarLessJson = lessToJs(varLessStr, { resolveVariables: true, stripPrefix: true });
// https://vitejs.dev/config/
export default defineConfig({
base: "/react-ant-admin",
build: {
outDir: "react-ant-admin"
},
define: {
MENU_PATH: `"path"`,
MENU_SHOW: `"show"`,
MENU_KEEPALIVE: `"keep_alive"`,
MENU_KEY: `"m_id"`,
MENU_ICON: `"icon"`,
MENU_TITLE: `"title"`,
MENU_CHILDREN: `"children"`,
MENU_PARENTKEY: `"parent_m_id"`,
MENU_ALLPATH: `"allPath"`,
MENU_PARENTPATH: `"parentPath"`,
MENU_LAYOUT: `'layout'`,
MENU_ORDER: `"order"`,
__IS_THEME__: `${process.env.REACT_APP_COLOR === "1"}`,
CUSTOMVARLESSDATA: `${JSON.stringify(customVarLessJson)}`
},
plugins: [
ReactRouterGenerator({
outputFile: resolve(".", "./src/router/auto.jsx"),
isLazy: true,
comKey: "components"
}),
react(),
],
resolve: {
alias: {
"@": resolve(".", "./src"),
"~": resolve(".", "./node_modules")
},
extensions: ['.mjs', '.js', '.ts', '.jsx', '.tsx', '.json', ".less"]
},
css: {
preprocessorOptions: {
less: {
modifyVars: { ...mapToken, ...customVarLessJson },
},
}
},
server: {
port: 3000,
open: false,
host: true,
proxy: {
'^/api': {
target: "https://z3web.cn",
changeOrigin: true,
rewrite: (path) => {
return path.replace("/api", "/api/react-ant-admin")
}
},
},
},
envPrefix: "REACT_APP_",
})
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
TypeScript
1
https://gitee.com/lujinfengg/react-ant-admin.git
git@gitee.com:lujinfengg/react-ant-admin.git
lujinfengg
react-ant-admin
react-ant-admin
vite

搜索帮助

0d507c66 1850385 C8b1a773 1850385