Ai
1 Star 0 Fork 0

zzz/react-vite

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
vite.config.js 2.67 KB
一键复制 编辑 原始数据 按行查看 历史
zzz 提交于 2022-09-26 17:10 +08:00 . axios 请求封装完成
import { fileURLToPath, URL } from "node:url";
import { defineConfig, loadEnv } from 'vite';
import react from '@vitejs/plugin-react';
import vitePluginImp from "vite-plugin-imp";
import { viteMockServe } from "vite-plugin-mock";
import { resolve } from "path";
// https://vitejs.dev/config/
export default defineConfig(function (_a) {
var command = _a.command, mode = _a.mode;
var env = loadEnv(mode, __dirname);
console.log("env", env);
return {
base: env.VITE_MODE == "production" ? "/react-vite/" : "/",
plugins: [
react(),
// 配置mock
viteMockServe({
mockPath: "/mock",
localEnabled: true
}),
vitePluginImp({
libList: [
{
libName: "antd",
style: function (name) { return "antd/es/".concat(name, "/style"); }
},
]
}),
],
css: {
//* css模块化
modules: {
// css模块化 文件以.module.[css|less|scss]结尾
generateScopedName: "[name]__[local]___[hash:base64:5]",
hashPrefix: "prefix"
},
//* 预编译支持less 并且设置主题颜色
preprocessorOptions: {
less: {
javascriptEnabled: true,
modifyVars: {
"primary-color": "#0fcb09",
"font-size-base": "20px",
"@border-radius-base": "10px"
}
}
}
},
resolve: {
alias: {
"@": fileURLToPath(new URL("./src", import.meta.url)),
"#": resolve(__dirname, '/src/types')
},
extensions: [".js", ".ts", "tsx"]
},
build: {
outDir: "dist",
// 兼容 Chrome 内核比较低的浏览器,如 360、QQ 浏览器
target: "chrome63",
cssTarget: "chrome63",
terserOptions: {
compress: {
keep_infinity: true,
// Used to delete console in production environment
drop_console: true
}
},
// Turning off brotliSize display can slightly reduce packaging time
reportCompressedSize: false,
chunkSizeWarningLimit: 2000
},
optimizeDeps: {
include: [
"antd/es/locale/zh_CN",
"antd/es/locale/en_US"
],
exclude: ["vue-demi", "consolidate"]
}
};
});
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
TypeScript
1
https://gitee.com/zzzPython/react-vite.git
git@gitee.com:zzzPython/react-vite.git
zzzPython
react-vite
react-vite
master

搜索帮助