UNPKG

gulp-uglify-es

Version:

gulp stream to uglify with 'uglify-es' (es6 supported).

21 lines (20 loc) 729 B
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); const o_stream_1 = require("o-stream"); const Uglify = require("uglify-es"); function plugin(options) { return o_stream_1.default.transform({ onEntered: (args) => { if (!args.object.contents) { throw new Error(`Invalid file with path: ${args.object.path}. The file has no contents.`); } let result = Uglify.minify(args.object.contents.toString(), options); if (result.error) { throw result.error; } args.object.contents = new Buffer(result.code); args.output.push(args.object); } }); } exports.default = plugin;