1 Star 0 Fork 194

zhangshitou/react-ant-admin_1

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
vite.config.ts 2.01 KB
一键复制 编辑 原始数据 按行查看 历史
import { defineConfig } from 'vite'
import react from '@vitejs/plugin-react'
import styleImport from 'vite-plugin-style-import';
import ReactRouterGenerator from "vite-plugin-react-router-generator"
import { resolve } from "path"
import { createHtmlPlugin } from 'vite-plugin-html'
function AntdLibImport() {
return {
libraryName: "antd",
esModule: true,
resolveStyle: (name) => {
return `antd/es/${name}/style/index`;
},
}
}
// 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"}`
},
plugins: [
ReactRouterGenerator({
outputFile: resolve(".", "./src/router/auto.jsx"),
isLazy: true,
comKey: "components"
}),
react(),
styleImport({ libs: [AntdLibImport()] }),
createHtmlPlugin({
inject: {
data: {
isShowColor: process.env.REACT_APP_COLOR === "1"
}
}
})
],
resolve: {
alias: {
"@": resolve(".", "./src"),
"~": resolve(".", "./node_modules")
},
extensions: ['.mjs', '.js', '.ts', '.jsx', '.tsx', '.json', ".less"]
},
css: {
preprocessorOptions: {
less: {
javascriptEnabled: true,
charset: false,
additionalData: `@import "${resolve(".", "./theme/var.less")}";`,
},
}
},
server: {
port: 3000,
open: false,
host: true,
proxy: {
'^/api': {
target: "https://azhengpersonalblog.top",
changeOrigin: true,
rewrite: (path) => {
return path.replace("/api", "/api/react-ant-admin")
}
},
},
},
envPrefix: "REACT_APP_",
})
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
TypeScript
1
https://gitee.com/zhang-xuepeng/react-ant-admin_1.git
git@gitee.com:zhang-xuepeng/react-ant-admin_1.git
zhang-xuepeng
react-ant-admin_1
react-ant-admin_1
vite

搜索帮助