You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
24 lines
710 B
24 lines
710 B
8 years ago
|
"use strict";
|
||
|
|
||
7 years ago
|
import fs = require("fs");
|
||
|
import path = require("path");
|
||
|
import UglifyJS = require("uglify-js");
|
||
8 years ago
|
|
||
7 years ago
|
export = (params, processor) => ({
|
||
7 years ago
|
"process": () => {
|
||
|
const filePath = path.normalize(path.join(processor.context.exported, params.filename));
|
||
8 years ago
|
const result = UglifyJS.minify(filePath);
|
||
7 years ago
|
|
||
8 years ago
|
fs.writeFile(filePath, result.code, (err) => {
|
||
|
if (err) {
|
||
7 years ago
|
processor.onError(`Unable to write uglified script for ${params.filename}: ${err}`);
|
||
8 years ago
|
} else {
|
||
7 years ago
|
processor.onInfo(`Saved uglified script for ${params.filename}; uglified length: ${result.code.length}`);
|
||
8 years ago
|
}
|
||
8 years ago
|
|
||
8 years ago
|
processor.done();
|
||
|
});
|
||
|
}
|
||
8 years ago
|
});
|
||
|
|