Skip to content

Commit

Permalink
[INTERNAL] added compressJSON flag
Browse files Browse the repository at this point in the history
  • Loading branch information
tobiasso85 authored and RandomByte committed Jan 16, 2020
1 parent 3aa1678 commit ce1236d
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 5 deletions.
11 changes: 7 additions & 4 deletions lib/processors/themeBuilder.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,10 @@ class ThemeBuilder {
* @param {module:@ui5/fs.Resource[]} resources Library files
* @param {Object} [options] Build options
* @param {boolean} [options.compress=false] Compress build output (CSS / JSON)
* @param {boolean} [options.compressJSON=false] Compress build output (JSON)
* @returns {Promise<module:@ui5/fs.Resource[]>} Resolving with array of created files
*/
build(resources, {compress = false} = {}) {
build(resources, {compress = false, compressJSON = false} = {}) {
const files = [];

const compile = (resource) => {
Expand Down Expand Up @@ -67,7 +68,7 @@ class ThemeBuilder {

const libParams = new Resource({
path: themeDir + "/library-parameters.json",
string: JSON.stringify(result.variables, null, compress ? null : "\t")
string: JSON.stringify(result.variables, null, compress || compressJSON ? null : "\t")
});

files.push(libCss, libCssRtl, libParams);
Expand Down Expand Up @@ -99,13 +100,15 @@ class ThemeBuilder {
* @param {module:@ui5/fs.Resource[]} parameters.resources List of <code>library.source.less</code> resources to be processed
* @param {fs|module:@ui5/fs.fsInterface} parameters.fs Node fs or custom [fs interface]{@link module:resources/module:@ui5/fs.fsInterface}
* @param {Object} [parameters.options] Options
* @param {Object} [parameters.options.compress=false] Compress build output (CSS / JSON)
* @param {boolean} [parameters.options.compress=false] Compress build output (CSS / JSON)
* @param {boolean} [parameters.options.compressJSON=false] Compress build output (JSON)
* @returns {Promise<module:@ui5/fs.Resource[]>} Promise resolving with theme resources
*/
module.exports = ({resources, fs, options}) => {
const themeBuilder = new ThemeBuilder({fs});
const compress = options && options.compress;
return themeBuilder.build(resources, {compress}).then((files) => {
const compressJSON = options && options.compressJSON;
return themeBuilder.build(resources, {compress, compressJSON}).then((files) => {
themeBuilder.clearCache();
return files;
});
Expand Down
5 changes: 4 additions & 1 deletion lib/tasks/buildThemes.js
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,10 @@ module.exports = async function({workspace, dependencies, options}) {
}
const processedResources = await themeBuilder({
resources,
fs: fsInterface(combo)
fs: fsInterface(combo),
options: {
compressJSON: true
}
});

const compress = options.compress === undefined ? true : options.compress;
Expand Down

0 comments on commit ce1236d

Please sign in to comment.