Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

可以配置需要处理依赖关系的文件扩展名 #4

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 7 additions & 4 deletions lib/layer.js
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,9 @@ var createHanlder = module.exports = function (res, options) {
// 模板目录
var views = options.views;

// 需要处理依赖关系的文件扩展名
var depthExt = options.depthExt || ['css', 'js'];

var loaded = [];

// include all async files
Expand Down Expand Up @@ -170,7 +173,7 @@ var createHanlder = module.exports = function (res, options) {
}
added[depId] = true;
var dep = fis.getInfo(depId, true);
if (!dep || (dep.type !== 'js' && dep.type !== 'css')) {
if (!dep || (depthExt.indexOf(dep.type) < 0)) {
return;
}
depList = depList.concat(getDepList(dep, added));
Expand All @@ -197,7 +200,7 @@ var createHanlder = module.exports = function (res, options) {
}
depScaned[depId] = true;
var dep = fis.getInfo(depId, true);
if (!dep || (dep.type !== 'js' && dep.type !== 'css')) {
if (!dep || depthExt.indexOf(dep.type) < 0) {
return;
}
asyncList = asyncList.concat(getAsyncList(dep, added, depScaned));
Expand All @@ -208,7 +211,7 @@ var createHanlder = module.exports = function (res, options) {
}
added[asyncId] = true;
var async = fis.getInfo(asyncId, true);
if (!async || (async.type !== 'js' && async.type !== 'css')) {
if (!async || (depthExt.indexOf(async.type) < 0)) {
return;
}
asyncList = asyncList.concat(getAsyncList(async, added, depScaned));
Expand Down Expand Up @@ -237,7 +240,7 @@ var createHanlder = module.exports = function (res, options) {
var depList = getDepList(file, addedSync);
var asyncList = getAsyncList(file, addedAsync, depScaned);
syncs = syncs.concat(depList);
if (file.type === 'js' || file.type === 'css') {
if ( (depthExt.indexOf(syncs.type) >= 0)) {
syncs.push(file);
}
asyncs = asyncs.concat(asyncList);
Expand Down