123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130 |
- // https://umijs.org/config/
- import os from "os";
- import pageRoutes from "./router.config";
- import webpackPlugin from "./plugin.config";
- import defaultSettings from "../src/defaultSettings";
- const isProd = process.env.NODE_ENV === "production";
- const plugins = [
- [
- "umi-plugin-react",
- {
- antd: true,
- dva: {
- hmr: !isProd,
- },
- targets: {
- ie: 11,
- },
- locale: {
- enable: true, // default false
- default: "zh-CN", // default zh-CN
- baseNavigator: false, // default true, when it is true, will use `navigator.language` overwrite default
- },
- dynamicImport: {
- loadingComponent: "./components/PageLoading/index",
- },
- pwa: {
- workboxPluginMode: "InjectManifest",
- workboxOptions: {
- importWorkboxFrom: "local",
- },
- },
- ...(!process.env.TEST && os.platform() === "darwin"
- ? {
- dll: {
- include: ["dva", "dva/router", "dva/saga", "dva/fetch"],
- exclude: ["@babel/runtime"],
- },
- }
- : {}),
- },
- ],
- ];
- // 针对 preview.pro.ant.design 的 GA 统计代码
- // 业务上不需要这个
- if (process.env.APP_TYPE === "site") {
- // plugins.push([
- // 'umi-plugin-ga',
- // {
- // code: 'UA-72788897-6',
- // },
- // ]);
- }
- export default {
- // add for transfer to umi
- plugins,
- targets: {
- ie: 11,
- },
- define: {
- APP_TYPE: process.env.APP_TYPE || "",
- },
- // 路由配置
- routes: pageRoutes,
- // Theme for antd
- // https://ant.design/docs/react/customize-theme-cn
- theme: {
- "primary-color": defaultSettings.primaryColor,
- },
- externals: {
- "@antv/data-set": "DataSet",
- },
- proxy: {
- "/api/": {
- target: "http://54.46.9.88:8001/",
- // target: 'http://192.168.0.158:8001/',
- changeOrigin: true,
- pathRewrite: { "^/api": "" },
- },
- },
- ignoreMomentLocale: true,
- lessLoaderOptions: {
- javascriptEnabled: true,
- },
- disableRedirectHoist: true,
- cssLoaderOptions: {
- modules: true,
- getLocalIdent: (context, localIdentName, localName) => {
- if (
- context.resourcePath.includes("node_modules") ||
- context.resourcePath.includes("ant.design.pro.less") ||
- context.resourcePath.includes("global.less")
- ) {
- return localName;
- }
- const match = context.resourcePath.match(/src(.*)/);
- if (match && match[1]) {
- const antdProPath = match[1].replace(".less", "");
- const arr = antdProPath
- .split("/")
- .map((a) => a.replace(/([A-Z])/g, "-$1"))
- .map((a) => a.toLowerCase());
- return `antd-pro${arr.join("-")}-${localName}`.replace(/--/g, "-");
- // return `${localName}`;
- }
- return localName;
- },
-
- // pluginOptions: {
- // "style-resources-loader": {
- // preProcessor: "less",
- // patterns: [
- // // 全局变量路径
- // path.resolve(__dirname, "./src/global.less"),
- // ],
- // },
- // }
- },
- manifest: {
- basePath: "/",
- },
- publicPath: "/",
- chainWebpack: webpackPlugin,
- // 开发环境关闭 source map 以提升速度
- devtool: isProd ? false : "cheap-module-source-map",
- };
|