Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

grunt-contrib-uglify

Package Overview
Dependencies
Maintainers
4
Versions
53
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

grunt-contrib-uglify - npm Package Compare versions

Comparing version 0.2.7 to 0.3.0

9

package.json
{
"name": "grunt-contrib-uglify",
"description": "Minify files with UglifyJS.",
"version": "0.2.7",
"version": "0.3.0",
"homepage": "https://github.com/gruntjs/grunt-contrib-uglify",

@@ -31,3 +31,4 @@ "author": {

"uglify-js": "~2.4.0",
"grunt-lib-contrib": "~0.6.1"
"grunt-lib-contrib": "~0.6.1",
"chalk": "~0.4.0"
},

@@ -46,3 +47,7 @@ "devDependencies": {

"gruntplugin"
],
"files": [
"tasks",
"LICENSE-MIT"
]
}

@@ -1,2 +0,2 @@

# grunt-contrib-uglify v0.2.6 [![Build Status](https://travis-ci.org/gruntjs/grunt-contrib-uglify.png?branch=master)](https://travis-ci.org/gruntjs/grunt-contrib-uglify)
# grunt-contrib-uglify v0.3.0 [![Build Status](https://travis-ci.org/gruntjs/grunt-contrib-uglify.png?branch=master)](https://travis-ci.org/gruntjs/grunt-contrib-uglify)

@@ -37,3 +37,3 @@ > Minify files with UglifyJS.

#### mangle
Type: `Boolean` `Object`
Type: `Boolean` `Object`
Default: `{}`

@@ -44,3 +44,3 @@

#### compress
Type: `Boolean` `Object`
Type: `Boolean` `Object`
Default: `{}`

@@ -51,3 +51,3 @@

#### beautify
Type: `Boolean` `Object`
Type: `Boolean` `Object`
Default: `false`

@@ -58,3 +58,3 @@

#### report
Choices: `false` `'min'` `'gzip'`
Choices: `false` `'min'` `'gzip'`
Default: `false`

@@ -73,16 +73,15 @@

#### sourceMap
Type: `String` `Function`
Default: `undefined`
Type: `Boolean`
Default: `false`
The location to output the sourcemap. If a function is provided, the uglify destination is passed as the argument
and the return value will be used as the sourceMap name.
If `true`, a source map file will be generated in the same directory as the `dest` file. By default it will have the same basename as the `dest` file, but with a `.map` extension.
#### sourceMapRoot
Type: `String`
#### sourceMapName
Type: `String` `Function`
Default: `undefined`
The location where your source files can be found. This sets the sourceRoot field in the source map.
To customize the name or location of the generated source map, pass a string to indicate where to write the source map to. If a function is provided, the uglify destination is passed as the argument and the return value will be used as the file name.
#### sourceMapIn
Type: `String` `Function`
Type: `String` `Function`
Default: `undefined`

@@ -94,17 +93,10 @@

#### sourceMappingURL
Type: `String` `Function`
Default: `undefined`
#### sourceMapIncludeSources
Type: `Boolean`
Default: `false`
The location of your sourcemap. Defaults to the location you use for sourceMap, override if you need finer control. Provide
a function to dynamically generate the sourceMappingURL based off the destination.
#### sourceMapPrefix
Type: `Number`
Default: `undefined`
The number of directories to drop from the path prefix when declaring files in the source map.
###### enclose
Type: `Object`
Type: `Object`
Default: `undefined`

@@ -116,3 +108,3 @@

#### wrap
Type: `String`
Type: `String`
Default: `undefined`

@@ -125,3 +117,3 @@

#### exportAll
Type: `Boolean`
Type: `Boolean`
Default: `false`

@@ -132,4 +124,4 @@

#### preserveComments
Type: `Boolean` `String` `Function`
Default: `undefined`
Type: `Boolean` `String` `Function`
Default: `undefined`
Options: `false` `'all'` `'some'`

@@ -145,3 +137,3 @@

#### banner
Type: `String`
Type: `String`
Default: empty string

@@ -152,3 +144,3 @@

#### footer
Type: `String`
Type: `String`
Default: empty string

@@ -160,3 +152,3 @@

[grunt.template.process]: https://github.com/gruntjs/grunt/wiki/grunt.template#wiki-grunt-template-process
[grunt.template.process]: http://gruntjs.com/api/grunt.template#grunt.template.process

@@ -380,2 +372,3 @@

* 2014-01-16   v0.3.0   refactor sourcemap support
* 2013-11-09   v0.2.7   prepending banner if sourceMap option not set, addresses

@@ -399,2 +392,2 @@ * 2013-11-08   v0.2.6   merged 45, 53, 85 (105 by way of duping 53) Added support for banners in uglified files with sourcemaps Updated docs

*This file was generated on Sat Nov 09 2013 12:42:05.*
*This file was generated on Thu Jan 16 2014 13:40:44.*

@@ -11,2 +11,4 @@ /*

var path = require('path');
// External libs.

@@ -29,2 +31,3 @@ var UglifyJS = require('uglify-js');

var totalCode = '';
var sourcesContent = {};

@@ -36,7 +39,15 @@ var outputOptions = getOutputOptions(options, dest);

files.forEach(function(file){
var code = grunt.file.read(file);
if (typeof options.sourceMapPrefix !== 'undefined') {
file = file.replace(/^\/+/, "").split(/\/+/).slice(options.sourceMapPrefix).join("/");
}
totalCode += code;
// The src file name must be relative to the source map for things to work
var basename = path.basename(file);
var fileDir = path.dirname(file);
var sourceMapDir = path.dirname(options.generatedSourceMapName);
var relativePath = path.relative(sourceMapDir, fileDir);
file = relativePath + path.sep + basename;
sourcesContent[file] = code;
topLevel = UglifyJS.parse(code, {

@@ -89,2 +100,10 @@ filename: file,

if (options.sourceMapIncludeSources) {
for (var file in sourcesContent) {
if (sourcesContent.hasOwnProperty(file)) {
outputOptions.source_map.get().setSourceContent(file, sourcesContent[file]);
}
}
}
// Print the ast to OutputStream

@@ -95,4 +114,5 @@ topLevel.print(output);

if (options.sourceMappingURL || options.sourceMap) {
min += "\n//# sourceMappingURL=" + (options.sourceMappingURL || options.sourceMap);
// Add the source map reference to the end of the file
if (options.sourceMap) {
min += "\n//# sourceMappingURL="+options.destToSourceMap;
}

@@ -148,2 +168,5 @@

if (options.sourceMap) {
var destBasename = path.basename(dest);
var destPath = path.dirname(dest);
var sourceMapIn;

@@ -154,8 +177,12 @@ if (options.sourceMapIn) {

outputOptions.source_map = UglifyJS.SourceMap({
file: dest,
root: options.sourceMapRoot,
file: destBasename,
orig: sourceMapIn
});
}
if (options.indentLevel !== undefined) {
outputOptions.indent_level = options.indentLevel;
}
return outputOptions;

@@ -162,0 +189,0 @@ };

@@ -11,2 +11,28 @@ /*

var path = require('path');
// Generate the default source map name
var getSourceMapLocation = function( dest ) {
var destExt = path.extname(dest);
var destDirname = path.dirname(dest);
var destBasename = path.basename(dest, destExt);
return destDirname + path.sep + destBasename + ".map";
};
// Return the relative path from file1 => file2
var relativePath = function(file1, file2) {
var file1Dirname = path.dirname(file1);
var file2Dirname = path.dirname(file2);
if (file1Dirname !== file2Dirname) {
return path.relative(file1Dirname, file2Dirname) + path.sep;
} else {
return "";
}
};
module.exports = function(grunt) {

@@ -18,2 +44,4 @@

var chalk = require('chalk');
grunt.registerMultiTask('uglify', 'Minify files with UglifyJS.', function() {

@@ -35,3 +63,3 @@ // Merge task-specific and/or target-specific options with these defaults.

var footer = grunt.template.process(options.footer);
var mapNameGenerator, mapInNameGenerator, mappingURLGenerator;
var mapNameGenerator, mapInNameGenerator;

@@ -56,7 +84,7 @@ // Iterate over all src-dest file pairs.

// function to get the name of the sourceMap
if (typeof options.sourceMap === "function") {
mapNameGenerator = options.sourceMap;
if (typeof options.sourceMapName === "function") {
mapNameGenerator = options.sourceMapName;
}
// function to get the name of the sourceMap
// function to get the name of the sourceMapIn file
if (typeof options.sourceMapIn === "function") {

@@ -69,13 +97,8 @@ if (src.length !== 1) {

// function to get the sourceMappingURL
if (typeof options.sourceMappingURL === "function") {
mappingURLGenerator = options.sourceMappingURL;
}
// dynamically create destination sourcemap name
if (mapNameGenerator) {
try {
options.sourceMap = mapNameGenerator(f.dest);
options.generatedSourceMapName = mapNameGenerator(f.dest);
} catch (e) {
var err = new Error('SourceMapName failed.');
var err = new Error('SourceMap failed.');
err.origError = e;

@@ -85,4 +108,10 @@ grunt.fail.warn(err);

}
// If no name is passed, generate the default name
else if ( !options.sourceMapName ) {
options.generatedSourceMapName = getSourceMapLocation( f.dest );
} else {
options.generatedSourceMapName = options.sourceMapName;
}
// dynamically create incoming sourcemap names
// Dynamically create incoming sourcemap names
if (mapInNameGenerator) {

@@ -98,11 +127,8 @@ try {

// dynamically create sourceMappingURL
if (mappingURLGenerator) {
try {
options.sourceMappingURL = mappingURLGenerator(f.dest);
} catch (e) {
var err = new Error('SourceMappingURL failed.');
err.origError = e;
grunt.fail.warn(err);
}
// Calculate the path from the dest file to the sourcemap for the
// sourceMappingURL reference
if (options.sourceMap) {
var destToSourceMapPath = relativePath(f.dest, options.generatedSourceMapName);
var sourceMapBasename = path.basename(options.generatedSourceMapName);
options.destToSourceMap = destToSourceMapPath + sourceMapBasename;
}

@@ -139,11 +165,10 @@

// Write source map
if (options.sourceMap) {
grunt.file.write(options.sourceMap, result.sourceMap);
grunt.log.writeln('Source Map "' + options.sourceMap + '" created.');
grunt.file.write(options.generatedSourceMapName, result.sourceMap);
grunt.log.writeln('File ' + chalk.cyan(options.generatedSourceMapName) + ' created (source map).');
}
// Print a success message.
grunt.log.writeln('File "' + f.dest + '" created.');
grunt.log.writeln('File ' + chalk.cyan(f.dest) + ' created.');

@@ -150,0 +175,0 @@ // ...and report some size information.

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc