grunt-contrib-uglify
Advanced tools
Comparing version 0.4.0 to 0.5.0
{ | ||
"name": "grunt-contrib-uglify", | ||
"description": "Minify files with UglifyJS.", | ||
"version": "0.4.0", | ||
"version": "0.5.0", | ||
"homepage": "https://github.com/gruntjs/grunt-contrib-uglify", | ||
@@ -32,6 +32,7 @@ "author": { | ||
"chalk": "^0.4.0", | ||
"maxmin": "^0.1.0" | ||
"maxmin": "^0.1.0", | ||
"lodash": "^2.4.1" | ||
}, | ||
"devDependencies": { | ||
"grunt-contrib-jshint": "^0.8.0", | ||
"grunt-contrib-jshint": "^0.10.0", | ||
"grunt-contrib-nodeunit": "^0.3.2", | ||
@@ -38,0 +39,0 @@ "grunt-contrib-clean": "^0.5.0", |
@@ -1,2 +0,2 @@ | ||
# grunt-contrib-uglify v0.4.0 [![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.5.0 [![Build Status: Linux](https://travis-ci.org/gruntjs/grunt-contrib-uglify.png?branch=master)](https://travis-ci.org/gruntjs/grunt-contrib-uglify) <a href="https://ci.appveyor.com/project/gruntjs/grunt-contrib-uglify"><img src="https://ci.appveyor.com/api/projects/status/ybtf5vbvtenii561/branch/master" alt="Build Status: Windows" height="18" /></a> | ||
@@ -48,2 +48,3 @@ > Minify files with UglifyJS. | ||
`sourceMapIncludeSources` - Embed the content of your source files directly into the map | ||
`expression` - Accepts a `Boolean` value. Parse a single expression (JSON or single functions) | ||
@@ -75,2 +76,8 @@ ### Options | ||
###### expression | ||
Type: `Boolean` | ||
Default: `false` | ||
Parse a single expression, rather than a program (for parsing JSON) | ||
#### report | ||
@@ -396,2 +403,4 @@ Choices: `'min'`, `'gzip'` | ||
* 2014-06-11 v0.5.0 added option "expression" to uglify json and single functions. Removes unnecessary source map function. Simplify default source map naming function. Normalizes header and footer linefeeds. Source map names follow specs. Updates sourcemapin fixture. | ||
* 2014-03-01 v0.4.0 remove grunt-lib-contrib dependency and add more colors | ||
* 2014-02-27 v0.3.3 remove unnecessary calls to `grunt.template.process` | ||
@@ -419,2 +428,2 @@ * 2014-01-22 v0.3.2 fix handling of `sourceMapIncludeSources` option. | ||
*This file was generated on Sat Mar 01 2014 20:36:24.* | ||
*This file was generated on Wed Jun 11 2014 17:27:16.* |
@@ -11,7 +11,7 @@ /* | ||
// External libs. | ||
var path = require('path'); | ||
// External libs. | ||
var fs = require('fs'); | ||
var UglifyJS = require('uglify-js'); | ||
var fs = require('fs'); | ||
var _ = require('lodash'); | ||
@@ -47,5 +47,6 @@ exports.init = function(grunt) { | ||
var relativePath = path.relative(sourceMapDir, fileDir); | ||
var pathPrefix = relativePath ? (relativePath+path.sep) : ""; | ||
var pathPrefix = relativePath ? (relativePath+path.sep) : ''; | ||
file = pathPrefix + basename; | ||
// Convert paths to use forward slashes for sourcemap use in the browser | ||
file = (pathPrefix + basename).replace(/\\/g, '/'); | ||
@@ -55,3 +56,4 @@ sourcesContent[file] = code; | ||
filename: file, | ||
toplevel: topLevel | ||
toplevel: topLevel, | ||
expression: options.expression | ||
}); | ||
@@ -67,3 +69,3 @@ }); | ||
if (options.enclose) { | ||
var argParamList = grunt.util._.map(options.enclose, function(val, key) { | ||
var argParamList = _.map(options.enclose, function(val, key) { | ||
return key + ':' + val; | ||
@@ -77,3 +79,5 @@ }); | ||
// and call after any compression or ast altering | ||
topLevel.figure_out_scope(); | ||
if (options.expression === false) { | ||
topLevel.figure_out_scope(); | ||
} | ||
@@ -118,3 +122,4 @@ if (options.compress !== false) { | ||
if (options.sourceMap) { | ||
min += "\n//# sourceMappingURL="+options.destToSourceMap; | ||
// Set all paths to forward slashes for use in the browser | ||
min += "\n//# sourceMappingURL="+options.destToSourceMap.replace(/\\/g, '/'); | ||
} | ||
@@ -147,3 +152,3 @@ | ||
outputOptions.comments = /^!|@preserve|@license|@cc_on/i; | ||
} else if (grunt.util._.isFunction(options.preserveComments)) { | ||
} else if (_.isFunction(options.preserveComments)) { | ||
@@ -160,6 +165,6 @@ // support custom functions passed in | ||
if (options.beautify) { | ||
if (grunt.util._.isObject(options.beautify)) { | ||
if (_.isObject(options.beautify)) { | ||
// beautify options sent as an object are merged | ||
// with outputOptions and passed to the OutputStream | ||
grunt.util._.extend(outputOptions, options.beautify); | ||
_.assign(outputOptions, options.beautify); | ||
} else { | ||
@@ -166,0 +171,0 @@ outputOptions.beautify = true; |
@@ -15,15 +15,4 @@ /* | ||
// 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) { | ||
function relativePath(file1, file2) { | ||
@@ -38,4 +27,9 @@ var file1Dirname = path.dirname(file1); | ||
}; | ||
} | ||
// Converts \r\n to \n | ||
function normalizeLf( string ) { | ||
return string.replace(/\r\n/g, '\n'); | ||
} | ||
module.exports = function(grunt) { | ||
@@ -55,8 +49,9 @@ // Internal lib. | ||
beautify: false, | ||
report: 'min' | ||
report: 'min', | ||
expression: false | ||
}); | ||
// Process banner. | ||
var banner = options.banner; | ||
var footer = options.footer; | ||
var banner = normalizeLf(options.banner); | ||
var footer = normalizeLf(options.footer); | ||
var mapNameGenerator, mapInNameGenerator; | ||
@@ -81,2 +76,9 @@ | ||
// Warn on incompatible options | ||
if (options.expression && (options.compress || options.mangle)) { | ||
grunt.log.warn('Option ' + chalk.cyan('expression') + ' not compatible with ' + chalk.cyan('compress and mangle')); | ||
options.compress = false; | ||
options.mangle = false; | ||
} | ||
// function to get the name of the sourceMap | ||
@@ -105,5 +107,5 @@ if (typeof options.sourceMapName === "function") { | ||
} | ||
// If no name is passed, generate the default name | ||
// If no name is passed append .map to the filename | ||
else if ( !options.sourceMapName ) { | ||
options.generatedSourceMapName = getSourceMapLocation( f.dest ); | ||
options.generatedSourceMapName = f.dest + '.map'; | ||
} else { | ||
@@ -110,0 +112,0 @@ options.generatedSourceMapName = options.sourceMapName; |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
27057
296
426
5
+ Addedlodash@^2.4.1