File tree Expand file tree Collapse file tree 6 files changed +76
-6
lines changed Expand file tree Collapse file tree 6 files changed +76
-6
lines changed Original file line number Diff line number Diff line change @@ -146,9 +146,9 @@ TENCENT_SECRET_ID=123
146
146
TENCENT_SECRET_KEY=123
147
147
```
148
148
149
- ## FAQ
149
+ ## 使用文档
150
150
151
- [ 参考 ] ( ./docs/faq .md )
151
+ [ 使用文档 ] ( ./docs/README .md )
152
152
153
153
## License
154
154
Original file line number Diff line number Diff line change
1
+ # 文档
2
+
3
+ ## 目录
4
+
5
+ - [ 全量配置] ( ./configure.md )
6
+ - [ 高级配置] ( ./advance.md )
7
+ - [ 常见问题] ( ./faq.md )
Original file line number Diff line number Diff line change
1
+ ## 高级配置
2
+
3
+ ### env
4
+
5
+ serverless 部署时会将 ` env ` 下配置的参数写入 ` env.js ` 文件中,将该文件打包上传到相对于 ` src ` 的 ` envPath ` 目录,默认为 ` src ` 指定目录。
6
+
7
+ 比如配置了:
8
+
9
+ ``` yaml
10
+ app : appDemo
11
+ stage : dev
12
+
13
+ component : website
14
+ name : websiteDemo
15
+
16
+ inputs :
17
+ src :
18
+ src : ./src
19
+ index : index.html
20
+ error : index.html
21
+ region : ap-guangzhou
22
+ bucketName : website-demo
23
+ protocol : https
24
+ # env 配置
25
+ env :
26
+ API_URL : https://api.com
27
+ ` ` `
28
+
29
+ 那么静态项目根目录下生成的 ` env.js` 文件内容如下:
30
+
31
+ ` ` ` js
32
+ window.env = {}
33
+ window.env.API_URL = 'https://api.com'
34
+ ` ` `
35
+
36
+ 然后,我们可以在前端项目中给所有的请求 URL 添加 `window.env.API_URL` 前缀,通常在全栈应用中,会使用到。比如在部署完后端服务后会生产后端服务网关 `url`,然后我们将上面的的 `API_URL` 赋值为后端服务的 `url`,就可以做到无需手动引入修改接口链接了。具体使用请参考 [全栈应用案例](https://github.com/serverless-components/tencent-examples/tree/master/fullstack)
37
+
38
+ # ## hook & dist
39
+
40
+ serverless cli 支持配置 `hook` 配置来帮用户执行部署前的命令,比如前端项目需要通过 `npm run build` 命令构建,然后才会部署,那么可以配置如下:
41
+
42
+ ` ` ` yaml
43
+ app: appDemo
44
+ stage: dev
45
+
46
+ component: website
47
+ name: websiteDemo
48
+
49
+ inputs:
50
+ src:
51
+ dist: ./dist
52
+ hook: npm run build
53
+ index: index.html
54
+ error: index.html
55
+ region: ap-guangzhou
56
+ bucketName: website-demo
57
+ protocol: https
58
+ ` ` `
59
+
60
+ - **hook**: 指定部署前需要执行的命令
61
+ - **dist**: 指定执行 `hook` 命令后,需要部署到云端的代码目录
62
+
63
+ > 注意:`hook` 必须和 `dist` 一起用。
Original file line number Diff line number Diff line change @@ -184,7 +184,7 @@ global:全球加速
184
184
185
185
### Env
186
186
187
- 环境变量参数文件。会将 env 下配置的参数写入 env.js 文件中,将该文件打包上传到你的代码里 。
187
+ 环境变量参数。serverless 部署时会将 ` env` 下配置的参数写入 ` env.js` 文件中,将该文件打包上传到相对于 `src` 的 `envPath` 目录,默认为 `src` 指定目录 。
188
188
189
189
比如配置了:
190
190
@@ -200,4 +200,4 @@ window.env = {}
200
200
window .env .API_URL = ' https://api.com'
201
201
```
202
202
203
- 让后我们可以在前端项目中给所有的请求 URL 添加 ` window.env.API_URL ` 前缀,通常在全栈应用中,会使用到。比如在部署完后端服务后会生产后端服务网关 ` url ` ,然后我们将上面的的 ` API_URL ` 赋值为后端服务的 ` url ` ,就可以做到无需手动引入修改接口链接了。具体使用请参考 [ 全栈应用案例] ( https://github.com/serverless-components/tencent-examples/tree/master/fullstack )
203
+ 然后,我们可以在前端项目中给所有的请求 URL 添加 ` window.env.API_URL ` 前缀,通常在全栈应用中,会使用到。比如在部署完后端服务后会生产后端服务网关 ` url ` ,然后我们将上面的的 ` API_URL ` 赋值为后端服务的 ` url ` ,就可以做到无需手动引入修改接口链接了。具体使用请参考 [ 全栈应用案例] ( https://github.com/serverless-components/tencent-examples/tree/master/fullstack )
Original file line number Diff line number Diff line change 1
1
app : appDemo
2
2
stage : dev
3
3
4
- component : website@dev
4
+ component : website
5
5
name : websiteDemo
6
6
7
7
inputs :
Original file line number Diff line number Diff line change 1
1
{
2
2
"dependencies" : {
3
3
"download" : " ^8.0.0" ,
4
- "tencent-component-toolkit" : " ^2.5.5 "
4
+ "tencent-component-toolkit" : " ^2.5.6 "
5
5
}
6
6
}
You can’t perform that action at this time.
0 commit comments