美文网首页
umi3 .umirc.ts 基本配置

umi3 .umirc.ts 基本配置

作者: 逸笛 | 来源:发表于2020-11-12 09:35 被阅读0次
import { defineConfig } from "umi";

export default defineConfig({
  nodeModulesTransform: {
    type: 'none',
  },

  //开启按需加载
  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 表示不开启  {} 表示开启
  //sass配置
  sass: {
  },
  request: {
    dataField: 'data',
  },
  routes: [
    { path: '/', component: '@/pages/Login/index' },
    { path: '/login', component: '@/pages/Login/index' },
    { path: '/home', component: '@/pages/Login/index' },
    { path: '/createLink', component: '@/pages/Home/CreateLink/index' },
    { path: '/manageLink', component: '@/pages/Home/ManageLink/index' },
    { path: '/extension', component: '@/pages/Home/Extension/index' },
  ],
  targets: { //配置浏览器最低版本,比如兼容ie11
    ie: 11
  },
  hash: true,  //开启打包文件的hash值后缀,
  proxy: {
    '/api': {
      'target': 'http://192.168.3.12:8028/',
      'changeOrigin': true,
      'pathRewrite': { '^/api' : '' },
    },
  },

});

相关文章

网友评论

      本文标题:umi3 .umirc.ts 基本配置

      本文链接:https://www.haomeiwen.com/subject/jupubktx.html