import { defineConfig } from "umi";
export default defineConfig({
nodeModulesTransform: {
type: 'none',
},
// 热更新
fastRefresh:{
},
// 标签页标题
title:'测试项目',
// 自定义加载页,默认为loading...
dynamicImport:{
loading:'@/pages/Loading',
},
// 标签页图标
links: [{ rel: 'icon', href: '/favicon.ico' }],
// 加快编译速度
mfsu:{},
//开启按需加载
dynamicImport: {
},
//开启按需加载后把 css 打包成一个文件
chainWebpack(config) {
config.optimization.splitChunks({
cacheGroups: {
styles: {
name: 'styles',
test: /\.(css|scss)$/,
chunks: 'async',
minChunks: 1,
minSize: 0,
}
},
});
},
//配置 externals 还能减小编译消耗
externals: {
'react': 'window.React',
'react-dom': 'window.ReactDOM',
'moment': 'window.moment',
'antd': 'window.antd',
},
scripts: [
'https://cdn.bootcdn.net/ajax/libs/react/17.0.1/umd/react.development.min.js',
'https://cdn.bootcdn.net/ajax/libs/react-dom/17.0.1/umd/react-dom.production.min.js',
'https://cdn.bootcdn.net/ajax/libs/moment.js/2.29.1/moment.min.js',
'https://cdnjs.cloudflare.com/ajax/libs/antd/4.8.2/antd.min.js',
],
//样式生效必须写在styles里面
styles: [ 'https://cdnjs.cloudflare.com/ajax/libs/antd/4.8.2/antd.min.css'],
dva: {
},
antd: false,//启用后自动配置 babel-plugin-import实现antd按需加载 false 表示不开启 {} 表示开启
antdMobile:false, // antd-mobile同理
//sass配置
sass: {
},
request: {
dataField: 'data',
},
// 路由配置
routes: [
{ path: '/', component: '@/pages/Login/index' },
{ path: '/login', component: '@/pages/Login/index' },
{ path: '/home', component: '@/pages/Home', routes: [
// { path: '/home', redirect: '/home/index' }, // 路由重定向,需要写在子路由中
{
path: '/home/index', component: '@/pages/index', name: 'string'
},
{
path: '/home/hot', component: '@/pages/Hot', name: '热门'
},
{ path: '/*', component: '@/pages/NotFound' }, },
],
targets: { //配置浏览器最低版本,比如兼容ie11
ie: 11
},
hash: true, //开启打包文件的hash值后缀,
proxy: {
'/api': {
'target': 'http://192.168.3.12:8028/',
'changeOrigin': true,
'pathRewrite': { '^/api' : '' },
},
},
});