forked from SAP/ui5-builder
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathuglify.js
26 lines (25 loc) · 887 Bytes
/
uglify.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
const uglifyProcessor = require("../processors/uglifier");
/**
* Task to minify resources.
*
* @public
* @alias module:@ui5/builder.tasks.uglify
* @param {Object} parameters Parameters
* @param {module:@ui5/fs.DuplexCollection} parameters.workspace DuplexCollection to read and write files
* @param {Object} parameters.options Options
* @param {string} parameters.options.pattern Pattern to locate the files to be processed
* @returns {Promise<undefined>} Promise resolving with <code>undefined</code> once data has been written
*/
module.exports = function({workspace, options}) {
return workspace.byGlobSource(options.pattern)
.then((allResources) => {
return uglifyProcessor({
resources: allResources
});
})
.then((processedResources) => {
return Promise.all(processedResources.map((resource) => {
return workspace.write(resource);
}));
});
};