1 Star 0 Fork 194

lg/react-ant-admin

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
vite.config.ts 1.92 KB
一键复制 编辑 原始数据 按行查看 历史
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: `"isShowOnMenu"`,
MENU_KEEPALIVE: `"keepAlive"`,
MENU_KEY: `"key"`,
MENU_ICON: `"icon"`,
MENU_TITLE: `"title"`,
MENU_CHILDREN: `"children"`,
MENU_PARENTKEY: `"parentKey"`,
MENU_ALLPATH: `"allPath"`,
MENU_PARENTPATH: `"parentPath"`,
MENU_LAYOUT: `'layout'`,
__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_",
})
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
TypeScript
1
https://gitee.com/taishandexiaocao/react-ant-admin.git
git@gitee.com:taishandexiaocao/react-ant-admin.git
taishandexiaocao
react-ant-admin
react-ant-admin
vite

搜索帮助