add optional support for cockpit to build process
This commit is contained in:
parent
de202c1eee
commit
183a0bf5ed
1 changed files with 36 additions and 11 deletions
|
|
@ -63,16 +63,24 @@ copy({
|
||||||
filter: [ copy.filter.moduleDefines ],
|
filter: [ copy.filter.moduleDefines ],
|
||||||
dest: cockpit
|
dest: cockpit
|
||||||
});
|
});
|
||||||
/*
|
|
||||||
// The graphics files
|
|
||||||
copy({
|
copy({
|
||||||
source: sources.map(function(source) {
|
source: [ {
|
||||||
return { root: aceHome, include: source + '/.*\\.png$' };
|
root: aceHome + '/support/cockpit/lib',
|
||||||
}, this),
|
include: /.*\.css$|.*\.html$/,
|
||||||
filter: [ copy.filter.base64, copy.filter.addDefines ],
|
exclude: /tests?\//
|
||||||
|
} ],
|
||||||
|
filter: [ copy.filter.addDefines ],
|
||||||
|
dest: cockpit
|
||||||
|
});
|
||||||
|
copy({
|
||||||
|
source: [ {
|
||||||
|
root: aceHome + '/support/cockpit/lib',
|
||||||
|
include: /.*\.png$|.*\.gif$/,
|
||||||
|
exclude: /tests?\//
|
||||||
|
} ],
|
||||||
|
filter: [ copy.filter.base64 ],
|
||||||
dest: cockpit
|
dest: cockpit
|
||||||
});
|
});
|
||||||
*/
|
|
||||||
|
|
||||||
// Ace sources
|
// Ace sources
|
||||||
var ace = copy.createDataObject();
|
var ace = copy.createDataObject();
|
||||||
|
|
@ -441,7 +449,25 @@ copy.filter.base64 = function(input, source) {
|
||||||
throw new Error('base64 filter needs to be the first in a filter set');
|
throw new Error('base64 filter needs to be the first in a filter set');
|
||||||
}
|
}
|
||||||
|
|
||||||
return 'define("text!' + source.toString() + '", ' + input + ');\n\n';
|
if (!source) {
|
||||||
|
throw new Error('Missing filename for moduleDefines');
|
||||||
|
}
|
||||||
|
|
||||||
|
if (source.base) {
|
||||||
|
source = source.path;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (source.substr(-4) === '.png') {
|
||||||
|
input = 'data:image/png;base64,' + input.toString('base64');
|
||||||
|
}
|
||||||
|
else if (source.substr(-4) === '.gif') {
|
||||||
|
input = 'data:image/gif;base64,' + input.toString('base64');
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
throw new Error('Only gif/png supported by base64 filter: ' + source);
|
||||||
|
}
|
||||||
|
|
||||||
|
return 'define("text!' + source + '", "' + input + '");\n\n';
|
||||||
};
|
};
|
||||||
copy.filter.base64.onRead = true;
|
copy.filter.base64.onRead = true;
|
||||||
|
|
||||||
|
|
@ -460,11 +486,10 @@ copy.filter.moduleDefines = function(input, source) {
|
||||||
if (source.base) {
|
if (source.base) {
|
||||||
source = source.path;
|
source = source.path;
|
||||||
}
|
}
|
||||||
|
source = source.replace(/\.js$/, '');
|
||||||
var module = source.replace(/\.js$/, '');
|
|
||||||
|
|
||||||
return input.replace(/\bdefine\(\s*function\(require,\s*exports,\s*module\)\s*\{/,
|
return input.replace(/\bdefine\(\s*function\(require,\s*exports,\s*module\)\s*\{/,
|
||||||
"define('" + module + "', function(require, exports, module) {");
|
"define('" + source + "', function(require, exports, module) {");
|
||||||
};
|
};
|
||||||
copy.filter.moduleDefines.onRead = true;
|
copy.filter.moduleDefines.onRead = true;
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue