@@ -18,6 +18,7 @@ const fsrUpload = require('./fsr');
18
18
* sandbox: {
19
19
* receiver: 'http://YOUR_HOST/receiver',
20
20
* templatePath: '/home/work/nginx_static/html/test/template',
21
+ * templateSuffix: '.tpl', // '.(san|html)'或 '\.(san|html)'
21
22
* staticPath: '//home/work/nginx_static/html/test/static',
22
23
* staticDomain: 'http://test.com:8888'
23
24
* }
@@ -37,6 +38,9 @@ class Upload {
37
38
} ;
38
39
this . throttle = options . throttle || 200 ;
39
40
this . compilationAssets = { } ;
41
+ const tplSuffix = options . templateSuffix || '.tpl' ;
42
+ // default: /\.tpl$/
43
+ this . tplReg = new RegExp ( ( tplSuffix . indexOf ( '.' ) === 0 ? '\\' : '' ) + tplSuffix + '$' ) ;
40
44
}
41
45
42
46
apply ( compiler ) {
@@ -51,7 +55,7 @@ class Upload {
51
55
// 过滤掉已经上传成功的文件
52
56
const compilationAssets = this . filterFiles ( compilation . assets ) ;
53
57
const targetFiles = Object . keys ( compilationAssets ) . map ( filename => {
54
- const to = / \. t p l $ / . test ( filename ) ? options . templatePath : options . staticPath ;
58
+ const to = this . tplReg . test ( filename ) ? options . templatePath : options . staticPath ;
55
59
return {
56
60
host : options . host ,
57
61
receiver : options . receiver ,
@@ -94,7 +98,7 @@ class Upload {
94
98
}
95
99
96
100
getContent ( filename , compilation ) {
97
- const isContainCdn = / \. ( c s s | j s | t p l ) $ / . test ( filename ) ;
101
+ const isContainCdn = / \. ( c s s | j s ) $ / . test ( filename ) || this . tplReg . test ( filename ) ; ;
98
102
const source = compilation . assets [ filename ] . source ( ) ;
99
103
if ( isContainCdn ) {
100
104
const reg = new RegExp ( this . options . baseUrl , 'g' ) ;
0 commit comments