Skip to content

Commit e4d946b

Browse files
committed
fix her/issues/23 and add test case
1 parent cf0829c commit e4d946b

File tree

4 files changed

+22
-15
lines changed

4 files changed

+22
-15
lines changed

plugins/outputHermap.js

+10-4
Original file line numberDiff line numberDiff line change
@@ -152,9 +152,13 @@ var exports = module.exports = function (ret, conf, settings, opt) {
152152
requireAsyncMap[id] = true;
153153
}
154154
});
155-
herId = fis.util.md5(content);
155+
156+
// 为了防止内容相同的不同defines生成相同的ID, md5加入了defines
157+
herId = [fis.util.md5(content), fis.util.md5(defines.join(','), 4)].join('_');
156158
//处理css
157159
if (pkg.file.isCssLike) {
160+
// TODO: 如何使pkg file的md5与生成pkgID时保持一致
161+
// 同file, css hook在content之后
158162
content += "\n" + ".css_" + herId + "{height:88px}";
159163
pkg.file.setContent(content);
160164
}
@@ -167,7 +171,6 @@ var exports = module.exports = function (ret, conf, settings, opt) {
167171
herRes.defines = defines;
168172
herRes.requires = deps;
169173
herRes.requireAsyncs = asyncs;
170-
171174
}
172175
});
173176
}
@@ -181,8 +184,11 @@ var exports = module.exports = function (ret, conf, settings, opt) {
181184
//生成herMap
182185
if (file.isJsLike || file.isCssLike) {
183186
content = file.getContent();
184-
herId = fis.util.md5(content);
185-
//处理css
187+
188+
// 为了防止内容相同的不同defines生成相同的ID, md5加入了defines
189+
// herId = fis.util.md5(content);
190+
herId = [fis.util.md5(content), fis.util.md5(file.id, 4)].join('_');
191+
// 处理css
186192
if (file.isCssLike) {
187193
content += "\n" + ".css_" + herId + "{height:88px}";
188194
file.setContent(content);

tests/normal-module/fis-conf.js

+8-11
Original file line numberDiff line numberDiff line change
@@ -7,17 +7,14 @@ fis.config.merge({
77
to: '../output'
88
}
99
},
10-
// pack : {
11-
// 'static/pkg/aio.css' : [
12-
// 'static/lib/css/bootstrap.css',
13-
// 'static/lib/css/bootstrap-responsive.css',
14-
// 'widget/**.css'
15-
// ],
16-
// 'static/pkg/aio.js' : [
17-
// 'static/lib/js/jquery-1.10.1.js',
18-
// 'widget/**.js'
19-
// ]
20-
// },
10+
pack : {
11+
'static/pkg/test.css' : [
12+
'static/test.css'
13+
],
14+
'static/pkg/test_copy.css' : [
15+
'static/test_copy.css'
16+
]
17+
},
2118
roadmap: {
2219
path: [{
2320
reg: /^\/widget\/(.*\.tpl)$/i,
+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
/* This is test.css */
2+
html{
3+
padding: 0;
4+
}

0 commit comments

Comments
 (0)