source: trip-planner-front/node_modules/css-minimizer-webpack-plugin/dist/minify.js@ 59329aa

Last change on this file since 59329aa was 6a3a178, checked in by Ema <ema_spirova@…>, 3 years ago

initial commit

  • Property mode set to 100644
File size: 1.5 KB
Line 
1"use strict";
2
3const minify = async options => {
4 const minifyFns = typeof options.minify === 'function' ? [options.minify] : options.minify;
5 const result = {
6 code: options.input,
7 map: options.inputSourceMap,
8 warnings: []
9 };
10
11 for (let i = 0; i <= minifyFns.length - 1; i++) {
12 const minifyFn = minifyFns[i];
13 const minifyOptions = Array.isArray(options.minifyOptions) ? options.minifyOptions[i] : options.minifyOptions; // eslint-disable-next-line no-await-in-loop
14
15 const minifyResult = await minifyFn({
16 [options.name]: result.code
17 }, result.map, minifyOptions);
18 result.code = minifyResult.code;
19 result.map = minifyResult.map;
20 result.warnings = result.warnings.concat(minifyResult.warnings || []);
21 }
22
23 if (result.warnings.length > 0) {
24 result.warnings = result.warnings.map(warning => warning.toString());
25 }
26
27 return result;
28};
29
30async function transform(options) {
31 // 'use strict' => this === undefined (Clean Scope)
32 // Safer for possible security issues, albeit not critical at all here
33 // eslint-disable-next-line no-new-func, no-param-reassign
34 const evaluatedOptions = new Function('exports', 'require', 'module', '__filename', '__dirname', `'use strict'\nreturn ${options}`)(exports, require, module, __filename, __dirname);
35 const result = await minify(evaluatedOptions);
36
37 if (result.error) {
38 throw result.error;
39 } else {
40 return result;
41 }
42}
43
44module.exports.minify = minify;
45module.exports.transform = transform;
Note: See TracBrowser for help on using the repository browser.