@node-minify/uglify-js
Version:
uglify-js plugin for @node-minify
66 lines (65 loc) • 2.38 kB
JavaScript
;
var __create = Object.create;
var __defProp = Object.defineProperty;
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
var __getOwnPropNames = Object.getOwnPropertyNames;
var __getProtoOf = Object.getPrototypeOf;
var __hasOwnProp = Object.prototype.hasOwnProperty;
var __copyProps = (to, from, except, desc) => {
if (from && typeof from === "object" || typeof from === "function") {
for (let key of __getOwnPropNames(from))
if (!__hasOwnProp.call(to, key) && key !== except)
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
}
return to;
};
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
// If the importer is in node compatibility mode or this is not an ESM
// file that has been converted to a CommonJS file using a Babel-
// compatible transform (i.e. "__esModule" has not been set), then set
// "default" to the CommonJS "module.exports" for node compatibility.
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
mod
));
// src/index.ts
var import_utils = require("@node-minify/utils");
var import_uglify_js = __toESM(require("uglify-js"));
var minifyUglifyJS = ({
settings,
content,
callback,
index
}) => {
const contentMinified = import_uglify_js.default.minify(content ?? "", settings?.options);
if (contentMinified.error) {
if (callback) {
return callback(contentMinified.error);
}
}
if (contentMinified.map && typeof settings?.options?.sourceMap === "object" && "filename" in settings.options.sourceMap) {
import_utils.utils.writeFile({
file: typeof settings.options.sourceMap.filename === "string" ? settings.options.sourceMap.filename : "",
content: contentMinified.map,
index
});
}
if (settings && !settings.content && settings.output) {
import_utils.utils.writeFile({
file: settings.output,
content: contentMinified.code,
index
});
}
if (callback) {
return callback(null, contentMinified.code);
}
return contentMinified.code;
};
minifyUglifyJS.default = minifyUglifyJS;
module.exports = minifyUglifyJS;
/*!
* node-minify
* Copyright(c) 2011-2024 Rodolphe Stoclin
* MIT Licensed
*/
//# sourceMappingURL=index.js.map