mirror of
https://github.com/WeBankFinTech/fes.js.git
synced 2025-04-06 03:59:53 +08:00
docs: update docs
This commit is contained in:
parent
3c66904896
commit
d9ecc01b86
@ -51,7 +51,7 @@ export default { mock: false };
|
|||||||
// .fes.local.js
|
// .fes.local.js
|
||||||
export default {
|
export default {
|
||||||
mock: true,
|
mock: true,
|
||||||
devServer: { port: 8080 }
|
devServer: { port: 8000 }
|
||||||
};
|
};
|
||||||
```
|
```
|
||||||
|
|
||||||
@ -60,7 +60,7 @@ export default {
|
|||||||
```js
|
```js
|
||||||
{
|
{
|
||||||
mock: true,
|
mock: true,
|
||||||
devServer: { port: 8080 }
|
devServer: { port: 8000 }
|
||||||
};
|
};
|
||||||
```
|
```
|
||||||
|
|
||||||
@ -81,7 +81,7 @@ export default { mock: false };
|
|||||||
// .fes.uat.js
|
// .fes.uat.js
|
||||||
export default {
|
export default {
|
||||||
mock: true,
|
mock: true,
|
||||||
devServer: { port: 8080 }
|
devServer: { port: 8000 }
|
||||||
};
|
};
|
||||||
```
|
```
|
||||||
|
|
||||||
@ -96,7 +96,7 @@ FES_ENV=uat fes dev
|
|||||||
```js
|
```js
|
||||||
{
|
{
|
||||||
mock: true,
|
mock: true,
|
||||||
devServer: { port: 8080 }
|
devServer: { port: 8000 }
|
||||||
};
|
};
|
||||||
```
|
```
|
||||||
|
|
||||||
|
@ -1,11 +1,13 @@
|
|||||||
# 环境变量
|
# 环境变量
|
||||||
在构建或者代码在端上运行中需要一些跟区分于环境的变量,用于配置构建流程或者运行时过程,这时候我们可以配置环境变量。
|
|
||||||
|
|
||||||
|
在构建或者代码在端上运行中需要一些跟区分于环境的变量,用于配置构建流程或者运行时过程,这时候我们可以配置环境变量。
|
||||||
|
|
||||||
## 配置环境变量
|
## 配置环境变量
|
||||||
|
|
||||||
### 命令行添加
|
### 命令行添加
|
||||||
|
|
||||||
比如:
|
比如:
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
# OS X, Linux
|
# OS X, Linux
|
||||||
PORT=3000 fes dev
|
PORT=3000 fes dev
|
||||||
@ -13,9 +15,10 @@ PORT=3000 fes dev
|
|||||||
# Windows (cmd.exe)
|
# Windows (cmd.exe)
|
||||||
set PORT=3000 && fes dev
|
set PORT=3000 && fes dev
|
||||||
```
|
```
|
||||||
|
|
||||||
如果要同时考虑 OS X 和 Windows,可借助三方工具 [cross-env](https://github.com/kentcdodds/cross-env)
|
如果要同时考虑 OS X 和 Windows,可借助三方工具 [cross-env](https://github.com/kentcdodds/cross-env)
|
||||||
<CodeGroup>
|
<CodeGroup>
|
||||||
<CodeGroupItem title="YARN" active>
|
<CodeGroupItem title="YARN" active>
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
yarn add cross-env --dev
|
yarn add cross-env --dev
|
||||||
@ -34,106 +37,135 @@ cross-env PORT=3000 fes dev
|
|||||||
</CodeGroup>
|
</CodeGroup>
|
||||||
|
|
||||||
### `.env` 文件配置
|
### `.env` 文件配置
|
||||||
|
|
||||||
Fes.js 中约定根目录下以 `.env` 开头的文件为环境变量配置文件。
|
Fes.js 中约定根目录下以 `.env` 开头的文件为环境变量配置文件。
|
||||||
|
|
||||||
比如:
|
比如:
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
PORT=3000
|
PORT=3000
|
||||||
```
|
```
|
||||||
|
|
||||||
然后执行
|
然后执行
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
fes dev
|
fes dev
|
||||||
```
|
```
|
||||||
|
|
||||||
会以 3000 端口启动 dev server。
|
会以 3000 端口启动 dev server。
|
||||||
|
|
||||||
#### 本地临时配置
|
#### 本地临时配置
|
||||||
|
|
||||||
可以新建 `.env.local`,这份配置会和 `.env` 做合并后形成最终配置。
|
可以新建 `.env.local`,这份配置会和 `.env` 做合并后形成最终配置。
|
||||||
|
|
||||||
#### 环境配置
|
#### 环境配置
|
||||||
|
|
||||||
可以通过环境变量 `FES_ENV` 区分不同环境来指定配置,这时候必须在执行命令前添加 `FES_ENV` 保证执行加载环境变量配置文件逻辑前 `FES_ENV` 已设置。
|
可以通过环境变量 `FES_ENV` 区分不同环境来指定配置,这时候必须在执行命令前添加 `FES_ENV` 保证执行加载环境变量配置文件逻辑前 `FES_ENV` 已设置。
|
||||||
|
|
||||||
举个 🌰 :
|
举个 🌰 :
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
FES_ENV=sit fes dev
|
FES_ENV=sit fes dev
|
||||||
```
|
```
|
||||||
|
|
||||||
如果存在 `.env.sit` 文件,则会将 `.env.sit` 的配置和 `.env` 做合并后形成最终配置。
|
如果存在 `.env.sit` 文件,则会将 `.env.sit` 的配置和 `.env` 做合并后形成最终配置。
|
||||||
|
|
||||||
#### 配置优先级
|
#### 配置优先级
|
||||||
|
|
||||||
本地临时配置 > 环境配置 > 基础配置
|
本地临时配置 > 环境配置 > 基础配置
|
||||||
|
|
||||||
::: tip
|
::: tip
|
||||||
如果多份配置中存在相同的配置项,**则优先级高的会覆盖优先级低的**。
|
如果多份配置中存在相同的配置项,**则优先级高的会覆盖优先级低的**。
|
||||||
:::
|
:::
|
||||||
|
|
||||||
## 编译时配置列表
|
## 编译时配置列表
|
||||||
|
|
||||||
编译时配置是在构建过程需要的变量,开放给用户配置。
|
编译时配置是在构建过程需要的变量,开放给用户配置。
|
||||||
|
|
||||||
### FES_ENV
|
### FES_ENV
|
||||||
|
|
||||||
指定当前的环境,不同环境各自的配置文件。
|
指定当前的环境,不同环境各自的配置文件。
|
||||||
::: tip
|
::: tip
|
||||||
`FES_ENV` 在会在加载`.env`前使用,所以只能用命令行方式配置。
|
`FES_ENV` 在会在加载`.env`前使用,所以只能用命令行方式配置。
|
||||||
:::
|
:::
|
||||||
|
|
||||||
### FES_PRESETS
|
### FES_PRESETS
|
||||||
|
|
||||||
添加额外的插件集入口
|
添加额外的插件集入口
|
||||||
|
|
||||||
### FES_PLUGINS
|
### FES_PLUGINS
|
||||||
|
|
||||||
添加额外的插件入口
|
添加额外的插件入口
|
||||||
|
|
||||||
### PORT
|
### PORT
|
||||||
`fes dev` 时服务指定的端口号,默认是 `8080`
|
|
||||||
|
`fes dev` 时服务指定的端口号,默认是 `8000`
|
||||||
|
|
||||||
### HOST
|
### HOST
|
||||||
|
|
||||||
默认是 `localhost`。
|
默认是 `localhost`。
|
||||||
|
|
||||||
### HTTPS
|
### HTTPS
|
||||||
|
|
||||||
默认是 `false`。
|
默认是 `false`。
|
||||||
|
|
||||||
### WATCH
|
### WATCH
|
||||||
|
|
||||||
设为 none 时不监听文件变更。比如:
|
设为 none 时不监听文件变更。比如:
|
||||||
|
|
||||||
```
|
```
|
||||||
WATCH=none fes dev
|
WATCH=none fes dev
|
||||||
```
|
```
|
||||||
|
|
||||||
### BABEL_CACHE
|
### BABEL_CACHE
|
||||||
|
|
||||||
默认开启 Babel 编译缓存,值为 none 时禁用缓存。
|
默认开启 Babel 编译缓存,值为 none 时禁用缓存。
|
||||||
|
|
||||||
### ANALYZE
|
### ANALYZE
|
||||||
|
|
||||||
用于分析 bundle 构成,默认关闭。
|
用于分析 bundle 构成,默认关闭。
|
||||||
|
|
||||||
比如:
|
比如:
|
||||||
|
|
||||||
```
|
```
|
||||||
ANALYZE=1 fes build
|
ANALYZE=1 fes build
|
||||||
```
|
```
|
||||||
|
|
||||||
### ANALYZE_MODE
|
### ANALYZE_MODE
|
||||||
|
|
||||||
默认是`server`
|
默认是`server`
|
||||||
|
|
||||||
### ANALYZE_PORT
|
### ANALYZE_PORT
|
||||||
|
|
||||||
默认是`8888`
|
默认是`8888`
|
||||||
|
|
||||||
### CLEAR_OUTPUT
|
### CLEAR_OUTPUT
|
||||||
|
|
||||||
仅仅在 `build` 时生效。如果设置为 `none`,就不会在构建前清除 `Output` 文件内容。
|
仅仅在 `build` 时生效。如果设置为 `none`,就不会在构建前清除 `Output` 文件内容。
|
||||||
|
|
||||||
### RM_TMPDIR
|
### RM_TMPDIR
|
||||||
|
|
||||||
仅仅在 `build` 时生效。如果设置为 `none`,就不会在构建后清除 `.fes` 临时文件内容。
|
仅仅在 `build` 时生效。如果设置为 `none`,就不会在构建后清除 `.fes` 临时文件内容。
|
||||||
|
|
||||||
## process.env
|
## process.env
|
||||||
|
|
||||||
运行时配置需要以 `FES_APP_` 开头,比如在 `.env` 中配置:
|
运行时配置需要以 `FES_APP_` 开头,比如在 `.env` 中配置:
|
||||||
|
|
||||||
```
|
```
|
||||||
FES_APP_KEY=123456789
|
FES_APP_KEY=123456789
|
||||||
```
|
```
|
||||||
|
|
||||||
在代码中使用:
|
在代码中使用:
|
||||||
|
|
||||||
```js
|
```js
|
||||||
console.log(process.env.FES_APP_KEY)
|
console.log(process.env.FES_APP_KEY);
|
||||||
// 输出 123456789
|
// 输出 123456789
|
||||||
```
|
```
|
||||||
|
|
||||||
除了用户自定义的以`FES_APP_`开头的变量,还提供如下配置:
|
除了用户自定义的以`FES_APP_`开头的变量,还提供如下配置:
|
||||||
|
|
||||||
- **NODE_ENV**:Node 环境变量
|
- **NODE_ENV**:Node 环境变量
|
||||||
|
|
||||||
- **FES_ENV**:Fes.js 环境变量
|
- **FES_ENV**:Fes.js 环境变量
|
||||||
|
|
||||||
- **BASE_URL**:等同于 publicPath
|
- **BASE_URL**:等同于 publicPath
|
||||||
|
@ -112,7 +112,7 @@ yarn dev
|
|||||||
|
|
||||||
yarn run v1.22.4
|
yarn run v1.22.4
|
||||||
$ fes dev
|
$ fes dev
|
||||||
Starting the development server http://localhost:8080 ...
|
Starting the development server http://localhost:8000 ...
|
||||||
|
|
||||||
✔ Webpack
|
✔ Webpack
|
||||||
Compiled successfully in 15.91s
|
Compiled successfully in 15.91s
|
||||||
@ -129,7 +129,7 @@ Starting the development server http://localhost:8080 ...
|
|||||||
npm run dev
|
npm run dev
|
||||||
|
|
||||||
> fes dev
|
> fes dev
|
||||||
Starting the development server http://localhost:8080 ...
|
Starting the development server http://localhost:8000 ...
|
||||||
|
|
||||||
✔ Webpack
|
✔ Webpack
|
||||||
Compiled successfully in 3.66s
|
Compiled successfully in 3.66s
|
||||||
@ -140,7 +140,7 @@ Starting the development server http://localhost:8080 ...
|
|||||||
</CodeGroupItem>
|
</CodeGroupItem>
|
||||||
</CodeGroup>
|
</CodeGroup>
|
||||||
|
|
||||||
Fes.js 会在 [http://localhost:8080](http://localhost:8080) 启动一个热重载的开发服务器。当你修改你的 .vue 文件时,浏览器中的内容也会自动更新。
|
Fes.js 会在 [http://localhost:8000](http://localhost:8000) 启动一个热重载的开发服务器。当你修改你的 .vue 文件时,浏览器中的内容也会自动更新。
|
||||||
|
|
||||||
<img :src="$withBase('home.png')" alt="home">
|
<img :src="$withBase('home.png')" alt="home">
|
||||||
|
|
||||||
|
@ -33,7 +33,7 @@ Usage:
|
|||||||
|
|
||||||
Options:
|
Options:
|
||||||
-c, --config <config> Set path to config file
|
-c, --config <config> Set path to config file
|
||||||
-p, --port <port> Use specified port (default: 8080)
|
-p, --port <port> Use specified port (default: 8000)
|
||||||
-t, --temp <temp> Set the directory of the temporary files
|
-t, --temp <temp> Set the directory of the temporary files
|
||||||
--host <host> Use specified host (default: 0.0.0.0)
|
--host <host> Use specified host (default: 0.0.0.0)
|
||||||
--cache <cache> Set the directory of the cache files
|
--cache <cache> Set the directory of the cache files
|
||||||
|
@ -96,6 +96,20 @@ export default {
|
|||||||
|
|
||||||
然后你代码里写 `console.log(__DEV__)`,会被编译成 `console.log('development')`。
|
然后你代码里写 `console.log(__DEV__)`,会被编译成 `console.log('development')`。
|
||||||
|
|
||||||
|
### builder
|
||||||
|
|
||||||
|
- 类型: `string`
|
||||||
|
- 默认值: 当前安装的 builder
|
||||||
|
- 详情:
|
||||||
|
比如 dev 用 vite,构建用 webpack
|
||||||
|
- 示例:
|
||||||
|
|
||||||
|
```js
|
||||||
|
export default {
|
||||||
|
builder: 'webpack',
|
||||||
|
};
|
||||||
|
```
|
||||||
|
|
||||||
### dynamicImport
|
### dynamicImport
|
||||||
|
|
||||||
- 类型: `boolean`
|
- 类型: `boolean`
|
||||||
|
Loading…
x
Reference in New Issue
Block a user