Skip to content

Commit 1a2dbd4

Browse files
committed
add ignore support
1 parent 77c0df8 commit 1a2dbd4

File tree

2 files changed

+75
-72
lines changed

2 files changed

+75
-72
lines changed

lib/page.js

Lines changed: 74 additions & 71 deletions
Original file line numberDiff line numberDiff line change
@@ -140,6 +140,7 @@ _.assign(module.exports.prototype, {
140140

141141
requires = requires.concat(obtainStyleFileIds);
142142
requires.forEach(function(fileId) { // 同步资源
143+
if (~conf.ignore.indexOf(fileId)) return;
143144
if (HTTP_REG.test(fileId)) return;
144145
if (!pageDepMap[fileId]) {
145146
pageDepMap[fileId] = self.calFileDepsFromId(fileId, pageRes);
@@ -169,6 +170,7 @@ _.assign(module.exports.prototype, {
169170
// - 3.1. 把url替换require.loadUrl里面的模块名
170171
// - 3.2. 在回调里面通过require获取模块
171172
loadUrls.concat(asyncs).forEach(function(fileId) { // 异步资源
173+
if (~conf.ignore.indexOf(fileId)) return;
172174
if (HTTP_REG.test(fileId)) return;
173175
if (!pageDepMap[fileId]) {
174176
pageDepMap[fileId] = self.calFileDepsFromId(fileId, pageRes);
@@ -335,16 +337,16 @@ _.assign(module.exports.prototype, {
335337
Object.keys(cssDeps).forEach(function(cssId) {
336338
cssFile = cssDeps[cssId];
337339

338-
if (conf.autoPack) {
339-
if (conf.cssInline) {
340-
html += '<style>' + cssFile.getContent() + '</style>' + LINE_BREAK;
341-
} else {
342-
// 业务
343-
pageCssList.push(cssFile);
344-
}
340+
// if (conf.autoPack) {
341+
if (conf.cssInline) {
342+
html += '<style>' + cssFile.getContent() + '</style>' + LINE_BREAK;
345343
} else {
346-
html += '<link rel="stylesheet" type="text/css" href="' + self._getUri(cssId) + '">' + LINE_BREAK;
344+
// 业务
345+
pageCssList.push(cssFile);
347346
}
347+
// } else {
348+
// html += '<link rel="stylesheet" type="text/css" href="' + self._getUri(cssId) + '">' + LINE_BREAK;
349+
// }
348350
});
349351

350352
if (conf.cssAllInOne) {
@@ -370,25 +372,26 @@ _.assign(module.exports.prototype, {
370372
conf = self.conf,
371373
pkg = self.pkg;
372374

373-
if (conf.autoPack) {
375+
// if (conf.autoPack) {
374376

375-
Object.keys(pkg).forEach(function(pId) {
376-
var pFile = pkg[pId];
377-
// ret.pkg 是全局的,所有页面都有打pkg里面全部的包
378-
if (pFile && !pFile.isAsync && pFile.isJsLike) {
379-
html += '<script src="' + pFile.getUrl() + '"></script>' + LINE_BREAK;
380-
}
381-
});
377+
Object.keys(pkg).forEach(function(pId) {
378+
var pFile = pkg[pId];
379+
// ret.pkg 是全局的,所有页面都有打pkg里面全部的包
380+
if (pFile && !pFile.isAsync && pFile.isJsLike) {
381+
html += '<script src="' + pFile.getUrl() + '"></script>' + LINE_BREAK;
382+
}
383+
});
382384

383385

384-
} else {
385-
Object.keys(pageRes).forEach(function(jsId) {
386-
jsFile = pageRes[jsId];
387-
if (jsFile.getContent() && !jsFile.isAsync) {
388-
html += '<script src="' + jsFile.getUrl() + '"></script>' + LINE_BREAK;
389-
}
390-
});
391-
}
386+
// } else {
387+
// Object.keys(pageRes).forEach(function(jsId) {
388+
// jsFile = pageRes[jsId];
389+
// if (jsFile.getContent() && !jsFile.isAsync) {
390+
// html += '<script src="' + jsFile.getUrl() + '"></script>' + LINE_BREAK;
391+
// }
392+
// });
393+
394+
// }
392395

393396
if (content.indexOf(conf.scriptPlaceHolder) !== -1) {
394397
content = content.replace(conf.scriptPlaceHolder, html);
@@ -604,58 +607,58 @@ _.assign(module.exports.prototype, {
604607
conf = self.conf,
605608
index = 0;
606609
// alias
607-
if (conf.autoPack) {
608-
Object.keys(analysis.depMap).forEach(function(p) {
609-
var combinedId = p + '.min',
610-
depDict = analysis.depMap[p].deps,
611-
file = analysis.depMap[p],
612-
pName = 'p' + index;
613-
if (!file.isAsync || self.isIdInLoadUrl(p)) {
614-
return;
615-
}
616-
Object.keys(depDict).forEach(function(fid) {
617-
resourceMap.res[fid] = {
618-
pkg: pName
619-
};
610+
// if (conf.autoPack) {
611+
Object.keys(analysis.depMap).forEach(function(p) {
612+
var combinedId = p + '.min',
613+
depDict = analysis.depMap[p].deps,
614+
file = analysis.depMap[p],
615+
pName = 'p' + index;
616+
if (!file.isAsync || self.isIdInLoadUrl(p)) {
617+
return;
618+
}
619+
Object.keys(depDict).forEach(function(fid) {
620+
resourceMap.res[fid] = {
621+
pkg: pName
622+
};
623+
624+
deps = self.generateJSDepList(fid);
620625

621-
deps = self.generateJSDepList(fid);
622-
623-
if (deps.length) {
624-
var _deps = [];
625-
deps.forEach(function(dep) {
626-
// filter sync module from deps
627-
if (self._sync.indexOf(dep) === -1) {
628-
_deps.push(dep);
629-
}
630-
});
631-
// filter requires
632-
if (_deps.length) {
633-
resourceMap.res[fid].deps = _deps;
626+
if (deps.length) {
627+
var _deps = [];
628+
deps.forEach(function(dep) {
629+
// filter sync module from deps
630+
if (self._sync.indexOf(dep) === -1) {
631+
_deps.push(dep);
634632
}
633+
});
634+
// filter requires
635+
if (_deps.length) {
636+
resourceMap.res[fid].deps = _deps;
635637
}
636-
});
637-
638-
resourceMap.pkg[pName] = {
639-
url: (ret.map.pkg[combinedId] || {}).uri
640-
}; // todo do i need to add deps?
641-
index++;
638+
}
642639
});
643640

644-
} else {
645-
Object.keys(analysis.pageRes).forEach(function(depId) {
646-
var file = analysis.pageRes[depId];
647-
if (file && file.isJsLike && file.isAsync) {
648-
resourceMap.res[depId] = {
649-
url: self._getUri(depId)
650-
};
651-
deps = self.generateJSDepList(depId);
641+
resourceMap.pkg[pName] = {
642+
url: (ret.map.pkg[combinedId] || {}).uri
643+
}; // todo do i need to add deps?
644+
index++;
645+
});
652646

653-
if (deps.length) {
654-
resourceMap.res[depId].deps = deps;
655-
}
656-
}
657-
});
658-
}
647+
// } else {
648+
// Object.keys(analysis.pageRes).forEach(function(depId) {
649+
// var file = analysis.pageRes[depId];
650+
// if (file && file.isJsLike && file.isAsync) {
651+
// resourceMap.res[depId] = {
652+
// url: self._getUri(depId)
653+
// };
654+
// deps = self.generateJSDepList(depId);
655+
656+
// if (deps.length) {
657+
// resourceMap.res[depId].deps = deps;
658+
// }
659+
// }
660+
// });
661+
// }
659662

660663
// process asyncMap
661664
Object.keys(analysis.asyncDeps).forEach(function(asyncId) {
@@ -717,7 +720,7 @@ _.assign(module.exports.prototype, {
717720
subpath,
718721
mainScriptFile;
719722

720-
if (conf.autoPack && conf.outputResourceMapToMainJs) {
723+
if (/*conf.autoPack && */conf.outputResourceMapToMainJs) {
721724
if (!this.mainScriptId) {
722725
this.getMainJs();
723726
}

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "fis3-packager-smart",
3-
"version": "0.7.6",
3+
"version": "0.7.7",
44
"description": "fis3 智能打包,分析页面依赖,自动打包同步、异步文件",
55
"keywords": [
66
"lego",

0 commit comments

Comments
 (0)