Ai
1 Star 0 Fork 0

zzz/react-vite

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
vite.config.ts 2.03 KB
一键复制 编辑 原始数据 按行查看 历史
zzz 提交于 2022-09-27 17:37 +08:00 . 增加 页面滚动监听时 节流操作demo
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(({ command, mode }) =>{
const 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: (name) => `antd/es/${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", //设置antd主题色
"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: "react-vite",
// 兼容 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

搜索帮助