Skip to content

Commit

Permalink
Add: comboMaxFiles opts
Browse files Browse the repository at this point in the history
Set `comboMaxFiles` opts in seajs and server.
It limits the number of files pre combo.
  • Loading branch information
Bacra committed May 4, 2015
1 parent 648805c commit 225cb81
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 1 deletion.
9 changes: 9 additions & 0 deletions dist/seajs-combo-debug.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ var comboHash = data.comboHash = {}

var comboSyntax = ["??", ","]
var comboMaxLength = 2000
var comboMaxFiles = 200
var comboExcludes
var comboSuffix

Expand All @@ -27,6 +28,7 @@ function setComboHash(uris) {
data.comboSyntax && (comboSyntax = data.comboSyntax)
data.comboMaxLength && (comboMaxLength = data.comboMaxLength)
data.comboSuffix && (comboSuffix = data.comboSuffix)
data.comboMaxFiles && (comboMaxFiles = data.comboMaxFiles)

comboExcludes = data.comboExcludes
var needComboUris = []
Expand Down Expand Up @@ -232,6 +234,13 @@ function setHash(root, files) {
for (var i = 0, len = files.length; i < len; i++) {
copy[i] = files[i].replace(/\?.*$/, '')
}
// server limit file num
if (files.length > comboMaxFiles) {
setHash(copy.splice(0, comboMaxFiles))
setHash(copy)
return
}

var comboPath = root + comboSyntax[0] + copy.join(comboSyntax[1])
if(comboSuffix) {
comboPath += comboSuffix
Expand Down
2 changes: 1 addition & 1 deletion dist/seajs-combo.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 9 additions & 0 deletions src/seajs-combo.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ var comboHash = data.comboHash = {}

var comboSyntax = ["??", ","]
var comboMaxLength = 2000
var comboMaxFiles = 200
var comboExcludes
var comboSuffix

Expand All @@ -26,6 +27,7 @@ function setComboHash(uris) {
data.comboSyntax && (comboSyntax = data.comboSyntax)
data.comboMaxLength && (comboMaxLength = data.comboMaxLength)
data.comboSuffix && (comboSuffix = data.comboSuffix)
data.comboMaxFiles && (comboMaxFiles = data.comboMaxFiles)

comboExcludes = data.comboExcludes
var needComboUris = []
Expand Down Expand Up @@ -231,6 +233,13 @@ function setHash(root, files) {
for (var i = 0, len = files.length; i < len; i++) {
copy[i] = files[i].replace(/\?.*$/, '')
}
// server limit file num
if (files.length > comboMaxFiles) {
setHash(copy.splice(0, comboMaxFiles))
setHash(copy)
return
}

var comboPath = root + comboSyntax[0] + copy.join(comboSyntax[1])
if(comboSuffix) {
comboPath += comboSuffix
Expand Down

0 comments on commit 225cb81

Please sign in to comment.