umi4.0版本已经发布的、,不知道3.0的版本你是否已经上手了。下面是umi 3.0基础版的配置文件,大家可以根据基础版本自行调整使用。
import { defineConfig } from 'umi';
const publicPath = '/';
export default defineConfig({
title: '3.0 模版', // 配置标题
mfsu: {}, // 快速热更新(目前bug较多,4.0版本会有较多优化)
ignoreMomentLocale: true, // 忽略 moment 的 locale 文件,用于减少尺寸
hash: true, // 文件 hash 后缀,通常用于增量发布和避免浏览器加载缓存。
externals: { // 哪些模块可以不被打包,通过 <script> 或其他方式引入,通常需要和 scripts 或 headScripts 配置同时使用。
config: 'window.CONFIG',
},
headScripts: [{ src: `${publicPath}config.js` }], // 配置 <head> 里的额外链接。
nodeModulesTransform: { // 设置目录下依赖文件的编译方式,不需要规避兼容性问题
type: 'none',
},
dynamicImport: { // 启用按需加载
loading: '@/components/Loading',
},
fastRefresh: {}, // 快速刷新,开发时可以保持组件状态,同时编辑提供即时反馈。
locale: { // 国际化配置
default: 'zh-CN', // 默认语言
antd: true, // 开启antd国际化
baseNavigator: false, // 取消浏览器语言检测
},
targets: { // 配置需要兼容的浏览器最低版本
android: 5,
ios: 7,
chrome: 58,
ie: 11,
},
lessLoader: { // 配置lessLoader
modifyVars: { // 引入一些less变量和less mixins,防止打包找不到prefix等less变量的问题
hack: 'true; @import "~@/styles/index.less";',
},
},
// 配置非根目录的部署
// base: publicPath
// publicPath,
// exportStatic: { dynamicRoot: true },
});