Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: gruntjs/grunt-contrib-uglify
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: v0.7.0
Choose a base ref
...
head repository: gruntjs/grunt-contrib-uglify
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: v0.8.0
Choose a head ref
  • 16 commits
  • 13 files changed
  • 8 contributors

Commits on Dec 29, 2014

  1. Add screwIE8 option.

    tswaters committed Dec 29, 2014
    Copy the full SHA
    69a91c2 View commit details
  2. Camel case

    tswaters committed Dec 29, 2014
    Copy the full SHA
    9a295df View commit details

Commits on Jan 1, 2015

  1. Update copyright to 2015

    shama committed Jan 1, 2015
    Copy the full SHA
    0b29bab View commit details

Commits on Jan 8, 2015

  1. Merge pull request #282 from tswaters/master

    Add screwIE8 option.
    vladikoff committed Jan 8, 2015
    Copy the full SHA
    ae723ac View commit details

Commits on Jan 23, 2015

  1. Fix screwIE8 option

    Alexey Zhigaltsov committed Jan 23, 2015
    Copy the full SHA
    4df8861 View commit details
  2. Merge pull request #290 from winamp/master

    Fix screwIE8 option
    vladikoff committed Jan 23, 2015
    Copy the full SHA
    d38ae2a View commit details

Commits on Feb 8, 2015

  1. Update .travis.yml

    sindresorhus committed Feb 8, 2015
    Copy the full SHA
    4547f91 View commit details
  2. package.json tweaks

    sindresorhus committed Feb 8, 2015
    Copy the full SHA
    badc615 View commit details

Commits on Feb 17, 2015

  1. Copy the full SHA
    a98ed47 View commit details

Commits on Feb 18, 2015

  1. Copy the full SHA
    c6c1414 View commit details
  2. Update appveyor.yml.

    XhmikosR committed Feb 18, 2015
    Copy the full SHA
    f4f0d9c View commit details
  3. Update dependencies.

    XhmikosR committed Feb 18, 2015
    Copy the full SHA
    e4af01d View commit details
  4. Regenerate README.md.

    [ci skip]
    XhmikosR committed Feb 18, 2015
    Copy the full SHA
    cbe19a2 View commit details

Commits on Feb 19, 2015

  1. Merge pull request #300 from shahata/explicit-compress

    Workaround issue with explicit compress in node 0.12.0
    sindresorhus committed Feb 19, 2015
    Copy the full SHA
    4a94468 View commit details
  2. changelog

    sindresorhus committed Feb 19, 2015
    Copy the full SHA
    435620e View commit details
  3. 0.8.0

    sindresorhus committed Feb 19, 2015
    Copy the full SHA
    82ab910 View commit details
Showing with 116 additions and 43 deletions.
  1. +4 −3 .travis.yml
  2. +5 −0 CHANGELOG
  3. +18 −1 Gruntfile.js
  4. +20 −6 README.md
  5. +20 −11 appveyor.yml
  6. +16 −3 docs/uglify-options.md
  7. +8 −15 package.json
  8. +9 −3 tasks/lib/uglify.js
  9. +7 −1 tasks/uglify.js
  10. +1 −0 test/fixtures/expected/compress_explicit.js
  11. +1 −0 test/fixtures/expected/screwIE8.js
  12. +5 −0 test/fixtures/src/screwIE8.js
  13. +2 −0 test/uglify_test.js
7 changes: 4 additions & 3 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
sudo: false
language: node_js
node_js:
- "0.10"
before_script:
- npm install -g grunt-cli
- 'iojs'
- '0.12'
- '0.10'
5 changes: 5 additions & 0 deletions CHANGELOG
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
v0.8.0:
date: 2015-02-19
changes:
- Add `screwIE8` option.
- Fix issue with explicit `compress` in node 0.12.0.
v0.7.0:
date: 2014-12-23
changes:
19 changes: 18 additions & 1 deletion Gruntfile.js
Original file line number Diff line number Diff line change
@@ -2,7 +2,7 @@
* grunt-contrib-uglify
* http://gruntjs.com/
*
* Copyright (c) 2014 "Cowboy" Ben Alman, contributors
* Copyright (c) 2015 "Cowboy" Ben Alman, contributors
* Licensed under the MIT license.
*/

@@ -38,6 +38,14 @@ module.exports = function(grunt) {
mangle: false
}
},
compress_explicit: {
files: {
'tmp/compress_explicit.js': ['test/fixtures/src/simple.js']
},
options: {
compress: true
}
},
compress_mangle: {
files: {
'tmp/compress_mangle.js': ['test/fixtures/src/simple.js']
@@ -129,6 +137,13 @@ module.exports = function(grunt) {
ASCIIOnly: true
}
},
screwIE8: {
src: 'test/fixtures/src/screwIE8.js',
dest: 'tmp/screwIE8.js',
options: {
screwIE8: true
}
},
exportAll: {
src: 'test/fixtures/src/simple.js',
dest: 'tmp/exportAll.js',
@@ -296,6 +311,7 @@ module.exports = function(grunt) {
'jshint',
'clean',
'uglify:compress',
'uglify:compress_explicit',
'uglify:compress_mangle',
'uglify:compress_mangle_banner',
'uglify:no_src',
@@ -307,6 +323,7 @@ module.exports = function(grunt) {
'uglify:wrap',
'uglify:maxLineLen',
'uglify:ASCIIOnly',
'uglify:screwIE8',
'uglify:exportAll',
'uglify:enclose',
'uglify:sourcemap_basic',
26 changes: 20 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
# grunt-contrib-uglify v0.7.0 [![Build Status: Linux](https://travis-ci.org/gruntjs/grunt-contrib-uglify.svg?branch=master)](https://travis-ci.org/gruntjs/grunt-contrib-uglify) [![Build Status: Windows](https://ci.appveyor.com/api/projects/status/ybtf5vbvtenii561/branch/master?svg=true)](https://ci.appveyor.com/project/gruntjs/grunt-contrib-uglify/branch/master)
# grunt-contrib-uglify v0.8.0 [![Build Status: Linux](https://travis-ci.org/gruntjs/grunt-contrib-uglify.svg?branch=master)](https://travis-ci.org/gruntjs/grunt-contrib-uglify) [![Build Status: Windows](https://ci.appveyor.com/api/projects/status/ybtf5vbvtenii561/branch/master?svg=true)](https://ci.appveyor.com/project/gruntjs/grunt-contrib-uglify/branch/master)

> Minify files with UglifyJS.


## Getting Started
This plugin requires Grunt `~0.4.0`
This plugin requires Grunt `>=0.4.0`

If you haven't used [Grunt](http://gruntjs.com/) before, be sure to check out the [Getting Started](http://gruntjs.com/getting-started) guide, as it explains how to create a [Gruntfile](http://gruntjs.com/sample-gruntfile) as well as install and use Grunt plugins. Once you're familiar with that process, you may install this plugin with this command:

@@ -58,19 +58,26 @@ This task primarily delegates to [UglifyJS2][], so please consider the [UglifyJS
Type: `Boolean` `Object`
Default: `{}`

Turn on or off mangling with default options. If an `Object` is specified, it is passed directly to `ast.mangle_names()` *and* `ast.compute_char_frequency()` (mimicking command line behavior).
Turn on or off mangling with default options. If an `Object` is specified, it is passed directly to `ast.mangle_names()` *and* `ast.compute_char_frequency()` (mimicking command line behavior). [View all options here](https://github.com/mishoo/UglifyJS2#mangler-options).



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

Turn on or off source compression with default options. If an `Object` is specified, it is passed as options to `UglifyJS.Compressor()`.

Turn on or off source compression with default options. If an `Object` is specified, it is passed as options to `UglifyJS.Compressor()`. [View all options here](https://github.com/mishoo/UglifyJS2#compressor-options).



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

Turns on beautification of the generated source code. An `Object` will be merged and passed with the options sent to `UglifyJS.OutputStream()`

Turns on beautification of the generated source code. An `Object` will be merged and passed with the options sent to `UglifyJS.OutputStream()`. [View all options here](https://github.com/mishoo/UglifyJS2#beautifier-options)


###### expression
Type: `Boolean`
@@ -176,6 +183,12 @@ Default: empty string

This string will be appended to the minified output. Template strings (e.g. `<%= config.value %>` will be expanded automatically.

#### screwIE8
Type: `Boolean`
Default: false

Pass this flag if you don't care about full compliance with Internet Explorer 6-8 quirks.

### Usage examples

#### Basic compression
@@ -419,6 +432,7 @@ grunt.initConfig({

## Release History

* 2015-02-19   v0.8.0   Add `screwIE8` option. Fix issue with explicit `compress` in node 0.12.0.
* 2014-12-23   v0.7.0   Adds sourceMapRoot options. Updates readme descriptions. Removes reference to cleancss.
* 2014-09-17   v0.6.0   Output fixes. ASCIIOnly option. Other fixes.
* 2014-07-25   v0.5.1   Chalk updates. Output updates.
@@ -445,4 +459,4 @@ grunt.initConfig({

Task submitted by ["Cowboy" Ben Alman](http://benalman.com)

*This file was generated on Tue Dec 23 2014 16:18:53.*
*This file was generated on Thu Feb 19 2015 16:25:10.*
31 changes: 20 additions & 11 deletions appveyor.yml
Original file line number Diff line number Diff line change
@@ -1,28 +1,37 @@
# appveyor file
# AppVeyor file
# http://www.appveyor.com/docs/appveyor-yml

# build version format
# Build version format
version: "{build}"

# fix lineendings in Windows
clone_depth: 10

# Fix line endings on Windows
init:
- git config --global core.autocrlf input
- git config --global core.autocrlf true

# what combinations to test
# What combinations to test
environment:
matrix:
- nodejs_version: 1.0
- nodejs_version: 0.12
- nodejs_version: 0.10

# Get the latest stable version of Node 0.STABLE.latest
install:
- ps: Update-NodeJsInstallation (Get-NodeJsLatestBuild $env:nodejs_version)
- ps: Install-Product node $env:nodejs_version
- npm install -g grunt-cli
- npm install

build: off

test_script:
- node --version
- npm --version
- ps: grunt test --no-color # PowerShell
- cmd: grunt test --no-color
- node --version && npm --version
- npm test

matrix:
fast_finish: true

cache:
- C:\Users\appveyor\AppData\Roaming\npm\node_modules # global npm modules
- C:\Users\appveyor\AppData\Roaming\npm-cache # npm cache
- node_modules # local npm modules
19 changes: 16 additions & 3 deletions docs/uglify-options.md
Original file line number Diff line number Diff line change
@@ -9,19 +9,26 @@ This task primarily delegates to [UglifyJS2][], so please consider the [UglifyJS
Type: `Boolean` `Object`
Default: `{}`

Turn on or off mangling with default options. If an `Object` is specified, it is passed directly to `ast.mangle_names()` *and* `ast.compute_char_frequency()` (mimicking command line behavior).
Turn on or off mangling with default options. If an `Object` is specified, it is passed directly to `ast.mangle_names()` *and* `ast.compute_char_frequency()` (mimicking command line behavior). [View all options here](https://github.com/mishoo/UglifyJS2#mangler-options).



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

Turn on or off source compression with default options. If an `Object` is specified, it is passed as options to `UglifyJS.Compressor()`.

Turn on or off source compression with default options. If an `Object` is specified, it is passed as options to `UglifyJS.Compressor()`. [View all options here](https://github.com/mishoo/UglifyJS2#compressor-options).



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

Turns on beautification of the generated source code. An `Object` will be merged and passed with the options sent to `UglifyJS.OutputStream()`

Turns on beautification of the generated source code. An `Object` will be merged and passed with the options sent to `UglifyJS.OutputStream()`. [View all options here](https://github.com/mishoo/UglifyJS2#beautifier-options)


#### expression
Type: `Boolean`
@@ -126,3 +133,9 @@ Type: `String`
Default: empty string

This string will be appended to the minified output. Template strings (e.g. `<%= config.value %>` will be expanded automatically.

## screwIE8
Type: `Boolean`
Default: false

Pass this flag if you don't care about full compliance with Internet Explorer 6-8 quirks.
23 changes: 8 additions & 15 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,19 +1,12 @@
{
"name": "grunt-contrib-uglify",
"description": "Minify files with UglifyJS.",
"version": "0.7.0",
"homepage": "https://github.com/gruntjs/grunt-contrib-uglify",
"version": "0.8.0",
"author": {
"name": "Grunt Team",
"url": "http://gruntjs.com/"
},
"repository": {
"type": "git",
"url": "git://github.com/gruntjs/grunt-contrib-uglify.git"
},
"bugs": {
"url": "https://github.com/gruntjs/grunt-contrib-uglify/issues"
},
"repository": "gruntjs/grunt-contrib-uglify",
"licenses": [
{
"type": "MIT",
@@ -28,27 +21,27 @@
},
"dependencies": {
"chalk": "^0.5.1",
"lodash": "^2.4.1",
"lodash": "^3.2.0",
"maxmin": "^1.0.0",
"uglify-js": "^2.4.0",
"uri-path": "0.0.2"
},
"devDependencies": {
"grunt": "^0.4.2",
"grunt-cli": "^0.1.13",
"grunt-contrib-clean": "^0.6.0",
"grunt-contrib-internal": "^0.4.2",
"grunt-contrib-jshint": "^0.10.0",
"grunt-contrib-internal": "^0.4.12",
"grunt-contrib-jshint": "^0.11.0",
"grunt-contrib-nodeunit": "^0.4.0"
},
"peerDependencies": {
"grunt": "~0.4.0"
"grunt": ">=0.4.0"
},
"keywords": [
"gruntplugin"
],
"files": [
"tasks",
"LICENSE-MIT"
"tasks"
],
"appveyor_id": "ybtf5vbvtenii561"
}
12 changes: 9 additions & 3 deletions tasks/lib/uglify.js
Original file line number Diff line number Diff line change
@@ -2,7 +2,7 @@
* grunt-contrib-uglify
* https://gruntjs.com/
*
* Copyright (c) 2014 "Cowboy" Ben Alman, contributors
* Copyright (c) 2015 "Cowboy" Ben Alman, contributors
* Licensed under the MIT license.
*/

@@ -74,18 +74,21 @@ exports.init = function(grunt) {
// Need to call this before we mangle or compress,
// and call after any compression or ast altering
if (options.expression === false) {
topLevel.figure_out_scope();
topLevel.figure_out_scope({screw_ie8: options.screwIE8});
}

if (options.compress !== false) {
if (options.compress === true) {
options.compress = {};
}
if (options.compress.warnings !== true) {
options.compress.warnings = false;
}
var compressor = UglifyJS.Compressor(options.compress);
topLevel = topLevel.transform(compressor);

// Need to figure out scope again after source being altered
topLevel.figure_out_scope();
topLevel.figure_out_scope({screw_ie8: options.screwIE8});
}

if (options.mangle !== false) {
@@ -165,6 +168,9 @@ exports.init = function(grunt) {
}
}

if (options.screwIE8) {
outputOptions.screw_ie8 = true;
}

if (options.sourceMap) {

8 changes: 7 additions & 1 deletion tasks/uglify.js
Original file line number Diff line number Diff line change
@@ -47,7 +47,8 @@ module.exports = function(grunt) {
report: 'min',
expression: false,
maxLineLen: 32000,
ASCIIOnly: false
ASCIIOnly: false,
screwIE8: false
});

// Process banner.
@@ -130,6 +131,11 @@ module.exports = function(grunt) {
options.destToSourceMap = destToSourceMapPath + sourceMapBasename;
}

if (options.screwIE8) {
if (options.mangle) { options.mangle.screw_ie8 = true; }
if (options.compress) { options.compress.screw_ie8 = true; }
}

// Minify files, warn and fail on error.
var result;
try {
1 change: 1 addition & 0 deletions test/fixtures/expected/compress_explicit.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions test/fixtures/expected/screwIE8.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
var reserved_words={class:!0};
5 changes: 5 additions & 0 deletions test/fixtures/src/screwIE8.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@

// screw-ie8 true will remove quotes
var reserved_words = {
'class': true
};
2 changes: 2 additions & 0 deletions test/uglify_test.js
Original file line number Diff line number Diff line change
@@ -14,6 +14,7 @@ exports.contrib_uglify = {
var files = [
'comments.js',
'compress.js',
'compress_explicit.js',
'compress_mangle.js',
'compress_mangle_banner.js',
'compress_mangle_beautify.js',
@@ -24,6 +25,7 @@ exports.contrib_uglify = {
'maxLineLen.js',
'asciionly.js',
'exportAll.js',
'screwIE8.js',
'sourcemap_basic.js',
'sourcemap_basic.js.map',
'sourcemap_customDir.js',