.env and Environment Variables
How to Configure
# OS X, Linux $ PORT=3000 umi dev # Windows (cmd.exe) $ set PORT=3000&&umi dev # Or use cross-env for all platforms $ yarn add cross-env --dev $ cross-env PORT=3000 umi dev # .env $ echo PORT=3000 > .env
Specifies a profile that overrides the default configuration. For example,
UMI_ENV=prod umi build, then
.umirc.js will be overwritten with
config/config.js. Note that overriding instead of replacing, configurators not in
.umirc.prod.js will use the configuration in
In addition, the configuration in
config/config.local.js in development mode is always the highest priority.
Specify the port number. The default is
8000. such as:
$ PORT=8001 umi dev
The default is
When ESLINT is set, the basic eslint check is done by eslint-config-umi in the dev and build commands. Avoid some simple mistakes.
APP_ROOT cannot be included in .env.
Specify the project root directory. such as:
$ APP_ROOT=src/renderer umi dev
It is off by default. Analyze the bundle composition, valid when building. Such as:
$ ANALYZE=1 umi build
It is off by default. Analyze the bundle composition and generate report json file (default
bundlestats.json ) for manual analysis and visualization. Such as:
$ ANALYZE_REPORT=1 umi build
Unlike the stat file generated by setting
ANALYZE and specifying
ANALYZE will directly dump [
[Webpack Stat] (https://webpack.js.org/configuration/stats/) data into target file, but
ANALYZE_REPORT will parse and trim Webpack Stat Data first, then generate report file, which can be use for analysis and visualization directly.
The advantagement is that we can get a smaller (only stat file 1% size) data file.
It is off by default. Analyze every webpack loader and plugin time consuming. Such as:
# Output speed measure info to terminal $ SPEED_MEASURE=CONSOLE umi build # Output speed measure info to node_modules/speed-measure.json $ SPEED_MEASURE=JSON umi build
ANALYZE server port, default 8888.
@babel/polyfill is included by default, set the value to
none if you don't want it.
$ BABEL_POLYFILL=none umi build
The default compression CSS and JS, the value is none when it is none, and it is valid when building. such as:
$ COMPRESS=none umi build
The default compression, the value is none without compression, and is valid at build time. Because css compression is sometimes problematic, and compression does not reduce the size, sometimes you can suppress JS without pressing CSS.
The browser is automatically opened by default. If the value is none, it will not be automatically opened. It is valid when dev. such as:
$ BROWSER=none umi dev
The default is cleared. If the value is none, the screen is not cleared.
The HMR is enabled by default, the value is disabled when none, and the value is refreshed when the file changes when reload.
.babelrc parsing, which is not resolved by default.
The babel cache is enabled by default, and is disabled when the value is none. such as:
$ BABEL_CACHE=none umi dev
The mock is enabled by default, and is disabled when the value is none. such as:
$ MOCK=none umi dev
The HTML file is packaged by default, and the HTML file is not packaged when the value is none. such as:
$ HTML=none umi build
$ FORK_TS_CHECKER=1 umi dev
socket server, default window.location.host. such as:
$ SOCKET_SERVER=http://localhost:8000 umi dev