Skip to content

Commit dde9830

Browse files
committed
新增template变量,已满足多页应用模拟问题
1 parent 2585432 commit dde9830

File tree

4 files changed

+10
-4
lines changed

4 files changed

+10
-4
lines changed

README.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,4 +16,6 @@ support mock for html base on html-webpack-plugin
1616
## test
1717
可支持之定义模板匹配规则
1818
## data
19-
渲染模板的模拟数据
19+
渲染模板的模拟数据
20+
## template
21+
模板名称(可选),要和html-webpack-plugin一致,主要是解决多页的情况

dist/index.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,9 @@ var MockHtml = function () {
4141

4242
compiler.plugin('compilation', function (compilation) {
4343
compilation.plugin('html-webpack-plugin-before-html-processing', function (data, cb) {
44-
data.html = _this.mock(data.html, _this.options.data);
44+
if (!_this.options.template || _this.options.template === data.outputName) {
45+
data.html = _this.mock(data.html, _this.options.data);
46+
}
4547
cb(null, data);
4648
});
4749
});

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "mock-html-webpack-plugin",
3-
"version": "0.2.0",
3+
"version": "0.2.1",
44
"description": "support mock for html when develop",
55
"main": "dist/index.js",
66
"files": [

src/index.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,9 @@ class MockHtml {
2121
apply (compiler) {
2222
compiler.plugin('compilation' , compilation => {
2323
compilation.plugin('html-webpack-plugin-before-html-processing', (data, cb) => {
24-
data.html = this.mock(data.html, this.options.data)
24+
if (!this.options.template || this.options.template === data.outputName) {
25+
data.html = this.mock(data.html, this.options.data)
26+
}
2527
cb(null, data)
2628
})
2729
})

0 commit comments

Comments
 (0)