uglify-loader
Advanced tools
Comparing version
24
index.js
var UglifyJS = require("uglify-js"); | ||
var loaderUtils = require('loader-utils'); | ||
module.exports = function(content) { | ||
this.cacheable(); | ||
module.exports = function(source, inputSourceMap) { | ||
var callback = this.async(); | ||
if (this.cacheable) { | ||
this.cacheable(); | ||
} | ||
var opts = this.options['uglify-loader'] || {}; | ||
// just an indicator to generate source maps, the output result.map will be modified anyway | ||
opts.outSourceMap = "out.map.js"; | ||
opts.fromString = true; | ||
return UglifyJS.minify(content, opts).code; | ||
var result = UglifyJS.minify(source, opts); | ||
var sourceFilename = loaderUtils.getRemainingRequest(this); | ||
var current = loaderUtils.getCurrentRequest(this); | ||
var sourceMap = JSON.parse(result.map); | ||
sourceMap.sources = [sourceFilename]; | ||
sourceMap.file = current; | ||
sourceMap.sourcesContent = [source]; | ||
callback(null, result.code, sourceMap); | ||
}; |
{ | ||
"name": "uglify-loader", | ||
"version": "1.1.0", | ||
"version": "1.2.0", | ||
"description": "Uglify.js loader for webpack", | ||
@@ -24,4 +24,5 @@ "main": "index.js", | ||
"dependencies": { | ||
"loader-utils": "^0.2.7", | ||
"uglify-js": "^2.4.16" | ||
} | ||
} |
Trivial Package
Supply chain riskPackages less than 10 lines of code are easily copied into your own project and may not warrant the additional supply chain risk of an external dependency.
Found 1 instance in 1 package
3537
21.09%19
216.67%0
-100%2
100%+ Added
+ Added
+ Added
+ Added
+ Added
+ Added