| sidebarDepth | 2 |
|---|
- Type:
Array - Default:
[]
Specify the plugin.
such as:
export default {
plugins: [
'umi-plugin-react',
// When the plugin has parameters, it is an array, and the second item of the array is a parameter, similar to the babel plugin.
['umi-plugin-react', {
dva: true,
}],
],
};- Type:
Array - Default:
null
Configure routing.
::: tip reminder
If routes is configured, the negotiated route will not take effect.
:::
- 类型:
Boolean - 默认值:
false
For some reason, we hoist all redirect when parsing the route config, but this caused some problems, so add this configuration to disable redirect hoist.
- Type:
String - Default:
browser
To switch the history mode to hash (the default is browser history), configure history: 'hash'.
- Type:
String - Default:
./dist
Specifies the output path.
- Type:
String - Default:
/
Specify the base of the react-router to be configured when deploying to a non-root directory.
- Type:
String - Default:
/
Specifies the publicPath of the webpack, pointing to the path where the static resource file is located.
- Type:
Boolean - Default:
false
Use the window.publicPath specified in the HTML when the value is true.
- Type:
String - Default: same as
publicPath
Specify an extra publicPath for CSS.
- Type:
String - Default:
root
Specifies the mount point id which the react app will mount to.
- Type:
Boolean - Default:
false
Whether to enable the hash file suffix.
- Type:
Object - Default:
{ chrome: 49, firefox: 45, safari: 10, edge: 13, ios: 10 }
配置浏览器最低版本,会自动引入 polyfill 和做语法转换,配置的 targets 会和合并到默认值,所以不需要重复配置。
Configuring the minimum version of browsers you want to compatible with.
e.g. Compatible with ie 11,
export default {
targets: {
ie: 11,
},
};- Type:
Object - Default:
{}
Configuring a global context will override the context in each page.
- Type:
Boolean | Object - Default:
false
If set to true or Object, all routes are exported as static pages, otherwise only one index.html is output by default.
such as:
"exportStatic": {}
- Type:
Boolean - Default:
false
Enable the .html suffix.
- Type:
Boolean - Default:
false
Deploy to any path.
- Type:
Boolean - Default:
false
If set to true, enable the directory for singular mode.
- src/layout/index.js
- src/page
- model (if umi-plugin-dva plugin is enabled)
Extend or modify the webpack configuration via the API of webpack-chain.
such as:
chainWebpack(config, { webpack }) {
// Set alias
config.resolve.alias.set('a', 'path/to/a');
// Delete progress bar plugin
config.plugins.delete('progress');
}The configuration theme is actually equipped with the less variable. Support for both object and string types, the string needs to point to a file that returns the configuration. such as:
"theme": {
"@primary-color": "#1DA57A"
}
or,
"theme": "./theme-config.js"
Passed to the code via the webP's DefinePlugin , the value is automatically handled by JSON.stringify.
such as:
"define": {
"process.env.TEST": 1,
"USE_COMMA": 2,
}Configure the externals property of webpack. such as:
// Configure react and react-dom do not enter the code
"externals": {
"react": "window.React",
"react-dom": "window.ReactDOM"
}Configure the resolve.alias property of webpack.
Configure the devtool property of webpack.
Disable CSS Modules.
Disable SourceMap generation for CSS.
Define an additional babel preset list in the form of an array.
Define an additional babel plugin list in the form of an array.
Define a list of additional files that need to be babel converted, in the form of an array, and the array item is webpack#Condition.
Define additional PostCSS plugins in the format of an array.
The files in the specified project directory do not go css modules, the format is an array, and the items must be css or less files.
Define a list of files that need to be copied simply. The format is an array. The format of the item refers to the configuration of copy-webpack-plugin.
such as:
"copy": [
{
"from": "",
"to": ""
}
]
Configure the proxy property of webpack-dev-server. If you want to proxy requests to other servers, you can do this:
"proxy": {
"/api": {
"target": "http://jsonplaceholder.typicode.com/",
"changeOrigin": true,
"pathRewrite": { "^/api" : "" }
}
}
Then visit /api/users to access the data of http://jsonplaceholder.typicode.com/users.
Configure options for node-sass. Note: The node-sass and sass-loader dependencies need to be installed in the project directory when using sass.
After configuration, manifest.json will be generated and the option will be passed to https://www.npmjs.com/package/webpack-manifest-plugin. such as:
"manifest": {
"basePath": "/app/"
}
Ignore the locale file for moment to reduce the size.
Additional configuration items for less-loader.
Additional configuration items for css-loader.Configure the resolve.alias property of webpack.
Configure browserslist to work with babel-preset-env and autoprefixer. such as:
"browserslist": [
"> 1%",
"last 2 versions"
]Configure the devtool property of webpack.
Disable CSS Modules.
Disable SourceMap generation for CSS.
Define an additional babel preset list in the form of an array.
Define an additional babel plugin list in the form of an array.
Define a list of additional files that need to be babel converted, in the form of an array, and the array item is webpack#Condition.
Define additional PostCSS plugins in the format of an array.
The files in the specified project directory do not go css modules, the format is an array, and the items must be css or less files.
Define a list of files that need to be copied simply. The format is an array. The format of the item refers to the configuration of copy-webpack-plugin.
such as:
"copy": [
{
"from": "",
"to": ""
}
]
Configure the proxy property of webpack-dev-server. If you want to proxy requests to other servers, you can do this:
"proxy": {
"/api": {
"target": "http://jsonplaceholder.typicode.com/",
"changeOrigin": true,
"pathRewrite": { "^/api" : "" }
}
}
Then visit /api/users to access the data of http://jsonplaceholder.typicode.com/users.
Configure options for node-sass. Note: The node-sass and sass-loader dependencies need to be installed in the project directory when using sass.
After configuration, manifest.json will be generated and the option will be passed to https://www.npmjs.com/package/webpack-manifest-plugin. such as:
"manifest": {
"basePath": "/app/"
}
Ignore the locale file for moment to reduce the size.
Additional configuration items for less-loader.
Additional configuration items for css-loader.