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.
22 lines
727 B
22 lines
727 B
"use strict";
|
|
|
|
import { writeFile } from "fs";
|
|
import { join, normalize } from "path";
|
|
import { minify } from "uglify-js";
|
|
|
|
import { GenericTask } from "../types";
|
|
|
|
export default ((params, processor) => () => {
|
|
const filePath = normalize(join(processor.context.exported, params.filename));
|
|
const result = minify(filePath);
|
|
|
|
writeFile(filePath, result.code, (err) => {
|
|
if (err) {
|
|
processor.onError(`Unable to write uglified script for ${params.filename}: ${err}`);
|
|
} else {
|
|
processor.onInfo(`Saved uglified script for ${params.filename}; uglified length: ${result.code.length}`);
|
|
}
|
|
|
|
processor.done();
|
|
});
|
|
}) as GenericTask<{ readonly filename: string }>;
|
|
|