# .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
# Environment Variables
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
Specify the base port number, umi will find available port to start dev server. The default is
8000. such as:
$ BASE_PORT=8001 umi dev
The default is
# ESLINT 2.4.0+
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
umi.server.js composition, valid when ssr building. Such as:
$ ANALYZE_SSR=1 umi build
Default is server. If you open ANALYZE, server mode will start HTTP server to show bundle report, disabled mode will just generate webpack stats file. Such as:
# Generate stats file to dist $ ANALYZE=1 ANALYZE_MODE=disabled umi build # Start http server to show bundle report $ ANALYZE=1 ANALYZE_MODE=server 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 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 2.2.0+
@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 output directory will be removed by default before each build, you can set it to
"none" to avoid it to be removed.
The HMR is enabled by default, the value is disabled when
none, and the value is refreshed when the file changes when reload.
The ERROR_OVERLAY is enabled by default, the value is disabled when
react-error-overlay won't display overlay whenever disabled.
.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
默认不开启 TypeScript 检查，值为 1 时启用。比如：
$ FORK_TS_CHECKER=1 umi dev
socket server, default window.location.host. such as:
$ SOCKET_SERVER=http://localhost:8000 umi dev
bind public ip when then value is
$ USE_PUBLIC_IP=true umi dev