forked from mojisrc/fashop-admin
-
Notifications
You must be signed in to change notification settings - Fork 0
/
.umirc.js
144 lines (137 loc) · 4.06 KB
/
.umirc.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
import os from "os";
import fs from "fs";
import pageRoutes from "./config/router.config";
import webpackPlugin from "./config/plugin.config";
import defaultSettings from "./src/defaultSettings";
// 默认接口地址
var host = "http://127.0.0.1:9510";
// .umirc.js当做fashop的默认配置,.build.js是为了方便在本地编译生产环境下的配置
if (fs.existsSync(".build.js")) {
const build = require("./.build.js");
if (build["host"] !== "undefined") {
host = build.host;
}
}
const plugins = [
[
"umi-plugin-react",
{
antd: true,
dva: {
hmr: true
},
locale: {
enable: true, // default false
default: "zh-CN", // default zh-CN
baseNavigator: true // default true, when it is true, will use `navigator.language` overwrite default
},
dynamicImport: {
loadingComponent: "./components/pageLoading/index"
},
pwa: {
workboxPluginMode: "InjectManifest",
workboxOptions: {
importWorkboxFrom: "local"
}
},
routes: {
exclude: [/\.test\.(j|t)sx?$/]
},
...(!process.env.TEST && os.platform() === "darwin"
? {
dll: {
include: ["dva", "dva/router", "dva/saga", "dva/fetch"],
exclude: ["@babel/runtime"]
},
hardSource: false
}
: {})
}
]
];
export default {
// add for transfer to umi
plugins,
targets: {
ie: 11
},
define: {
APP_TYPE: process.env.APP_TYPE || "",
"process.env.dev": {
websocket: {
host: host.replace("http", "ws")
}
// 开发环境下的api走proxy
},
"process.env.production": {
websocket: {
host: host.replace("http", "ws")
},
api: {
url: host
}
}
},
// 路由配置
routes: pageRoutes,
// Theme for antd
// https://ant.design/docs/react/customize-theme-cn
theme: {
"primary-color": defaultSettings.primaryColor,
"layout-header-background": "#000",
"menu-bg": "#000",
"menu-dark-bg": "#000",
"menu-dark-submenu-bg": "#151515"
},
externals: {
"@antv/data-set": "DataSet"
},
/**
* 部署(build)模式下无效,仅供开发环境下
*/
proxy: {
"/admin": {
target: host,
changeOrigin: true,
pathRewrite: { "^/admin": "/admin" },
secure: false
},
"/install/installer": {
target: host,
changeOrigin: true,
pathRewrite: { "^/install/installer": "/install/installer" },
secure: false
}
},
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;
}
},
manifest: {
basePath: "/"
},
chainWebpack: webpackPlugin
};