Skip to content

Commit b83ece6

Browse files
authored
Merge pull request #339 from zttonly/master
remote增加模板后缀配置
2 parents 3926b4c + a6f6c93 commit b83ece6

File tree

6 files changed

+19
-9
lines changed

6 files changed

+19
-9
lines changed

docs/deployment.md

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33
# 部署
44
在执行 `san build [entry] --remote <remote-name>` 时,使用的就是该页面的远程部署解决方案,支持从项目本地将生产环境编译产出直接远程部署到目标开发机。
55

6+
如需在开发中代码每次更改自动部署至远端机器,实现代码更改实时push,可执行 `san build [entry] --watch --remote <remote-name>` 命令
7+
68
使用时,需要进行相应的 **环境配置** 以及 **参数配置**,下面具体说明如何配置。
79

810
## 环境配置
@@ -15,6 +17,7 @@
1517
SAN_REMOTE_XIAOMING_DISABLE_FSR=true
1618
SAN_REMOTE_XIAOMING_RECEIVER=http://www.xiaoming.com:8080/receiver.php
1719
SAN_REMOTE_XIAOMING_TEMPLATE_PATH=/home/work/nginx_static/html/test/template
20+
SAN_REMOTE_XIAOMING_TEMPLATE_SUFFIX=.html
1821
SAN_REMOTE_XIAOMING_STATIC_PATH=/home/work/nginx_static/html/test/static
1922
SAN_REMOTE_XIAOMING_STATIC_DOMAIN=http://test.bdstatic.com:8888
2023
SAN_REMOTE_XIAOMING_BASE_URL=http://www.cdnstatic.com
@@ -24,7 +27,7 @@ SAN_REMOTE_XIAOMING_HOST=http://www.xiaoming.com:8080
2427

2528
::: warning 上例解读
2629
1. 命名规则:**SAN_REMOTE_(1.大写的 remote-name 名称)_ (2.大写的参数名称,驼峰处改用下划线分隔)**;其中【1】的与remote-name相同,【2】会解析为配置参数,具体含义见**参数配置**
27-
2. 将 tpl、js、css 文件代码中 http://www.cdnstatic.com 替换成了 http://test.bdstatic.com:8888
30+
2. 将模板(默认tpl)、js、css 文件代码中 http://www.cdnstatic.com 替换成了 http://test.bdstatic.com:8888
2831
:::
2932

3033
### 远端机器
@@ -43,7 +46,12 @@ SAN_REMOTE_XIAOMING_HOST=http://www.xiaoming.com:8080
4346
远程服务的 receiver.php 地址,receiver.php 文件内容[参考](https://github.com/fex-team/fis3-deploy-http-push/blob/master/receiver.php)
4447

4548
#### `templatePath`
46-
远程服务的模板存放地址,产出文件中的 .tpl 结尾的文件会上传到此路径下。
49+
远程服务的模板存放地址,产出文件中的 .tpl (默认后缀, 可通过templateSuffix修改) 结尾的文件会上传到此路径下。
50+
51+
#### `templateSuffix`
52+
项目中模板文件后缀,如:'.html',不配置时默认 '.tpl'
53+
54+
>> san-cli-build > 2.1.1 & deploy-files > 0.2.3 支持
4755
4856
#### `staticPath`
4957
远程服务的静态文件存放地址。
@@ -76,7 +84,7 @@ san build --remote xiaoming --watch
7684

7785
## 简单说实现
7886

79-
使用[deploy-files](https://github.com/jinzhan/deploy-files)插件。
87+
使用[deploy-files](https://github.com/wanwu/deploy-files)插件。
8088

8189
安装 deploy-files (版本 >= 0.1.1):
8290

docs/env.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ SAN_VAR_TRUE=true
3434
# .env.production
3535
SAN_REMOTE_XIAOMING_RECEIVER=http://www.xiaoming.com:8080/receiver.php
3636
SAN_REMOTE_XIAOMING_TEMPLATE_PATH=/home/work/nginx_static/html/test/template
37+
SAN_REMOTE_XIAOMING_TEMPLATE_SUFFIX=.html # 可选
3738
SAN_REMOTE_XIAOMING_STATIC_PATH=/home/work/nginx_static/html/test/static
3839
SAN_REMOTE_XIAOMING_STATIC_DOMAIN=http://test.bdstatic.com:8888
3940
```

packages/san-cli-build/getWebpackConfig.js

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -63,15 +63,16 @@ module.exports = function getNormalizeWebpackConfig(api, projectConfigs, argv) {
6363
if (remote) {
6464
const DeployPlugin = require('deploy-files/webpack-plugin');
6565
// 从 env 文件中读取 remote 配置,这样可以将 env.local 加到 .gitignore 中防止提交
66-
// 详细配置:https://github.com/jinzhan/deploy-files
66+
// 详细配置:https://github.com/wanwu/deploy-files
6767
// host: 'http://YOUR_HOST'
6868
// receiver: 'http://YOUR_HOST/receiver',
6969
// templatePath: '/home/work/nginx_static/html/test/template',
70+
// templateSuffix: '.html',
7071
// staticPath: '//home/work/nginx_static/html/test/static',
7172
// staticDomain: 'http://test.com:8888'
7273
// baseUrl: 'https://s.bdstatic.com/'
7374
const upperRemote = remote.toUpperCase();
74-
const requiredParam = ['templatePath', 'staticPath', 'staticDomain', 'baseUrl'];
75+
const requiredParam = ['templatePath', 'staticPath', 'staticDomain', 'baseUrl', 'templateSuffix'];
7576
const remoteObj = {
7677
// 1. 默认取false;
7778
// 2. process.env读取的内容为string,需转boolean
@@ -83,7 +84,7 @@ module.exports = function getNormalizeWebpackConfig(api, projectConfigs, argv) {
8384
// templatePath → TEMPLATE_PATH
8485
const upperKey = key.replace(/[A-Z]/g, $1 => `_${$1}`).toUpperCase();
8586
const val = process.env[`SAN_REMOTE_${upperRemote}_${upperKey}`];
86-
if (!val) {
87+
if (key !== 'templateSuffix' && !val) {
8788
error(
8889
/* eslint-disable max-len */
8990
`Use --remote ${remote} to upload files, but donot get ${chalk.red(

packages/san-cli-plugin-babel/__tests__/preset.spec.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ test('async/await', () => {
9191
await Promise.resolve();
9292
}
9393
`, defaultOptions);
94-
expect(code).toMatch('regenerator-runtime/runtime');
94+
expect(code).toMatch('regeneratorRuntime');
9595
});
9696

9797
test('显式传入 polyfill', () => {

packages/san-cli/__tests__/e2e.spec.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
// 运行测试的时间上限设为6分钟(默认是5秒,太短了不够用)
2-
jest.setTimeout(360000);
2+
jest.setTimeout(390000);
33

44
const path = require('path');
55
const child_process = require('child_process');

packages/san-cli/__tests__/serveSan.spec.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
jest.setTimeout(30000);
1+
jest.setTimeout(32000);
22

33
const child_process = require('child_process');
44
const puppeteer = require('puppeteer');

0 commit comments

Comments
 (0)