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.8.1
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.9.0
Choose a head ref
  • 7 commits
  • 26 files changed
  • 4 contributors

Commits on Apr 2, 2015

  1. Updated grunt wrapper to be able to hook into uglify's new object pro…

    …perty name mangling functionality, the ability to pass files containing property and variable name exceptions and the ability to use a cache to coordinate symbol mangling across multiple calls to uglify.
    
    See uglifyjs v2.4.18 https://www.npmjs.com/package/uglify-js for more info.
    jrhite committed Apr 2, 2015

    Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
    Copy the full SHA
    809fb2e View commit details
  2. Merge pull request #312 from jrhite/master

    Incorporate uglify's new object property mangling capabilities
    XhmikosR committed Apr 2, 2015

    Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
    Copy the full SHA
    fb0f29a View commit details
  3. Simplify Gruntfile.js.

    XhmikosR committed Apr 2, 2015

    Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
    Copy the full SHA
    ee40525 View commit details

Commits on Apr 5, 2015

  1. Adding quote_style option. Fixes #293.

    Ændrew Rininsland committed Apr 5, 2015

    Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
    Copy the full SHA
    9704819 View commit details

Commits on Apr 6, 2015

  1. Merge pull request #306 from aendrew/293_adding_quote_style_option

    Adding quote_style option. Fixes #293.
    XhmikosR committed Apr 6, 2015

    Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
    Copy the full SHA
    f180390 View commit details
  2. Update README.md

    [ci skip]
    XhmikosR committed Apr 6, 2015
    2
    Copy the full SHA
    672d94a View commit details

Commits on Apr 7, 2015

  1. v0.9.0

    vladikoff committed Apr 7, 2015
    Copy the full SHA
    5eefc88 View commit details
2 changes: 1 addition & 1 deletion .editorconfig
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
root = true

[*]
indent_style = spaces
indent_style = space
indent_size = 2
end_of_line = lf
insert_final_newline = true
6 changes: 5 additions & 1 deletion CHANGELOG
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
v0.9.0:
date: 2015-04-07
changes:
- added hook into uglify's mangling functionality
v0.8.1:
date: 2015-02-19
date: 2015-03-30
changes:
- lock uglify to 2.4.17 due to breaking changes
v0.8.0:
111 changes: 82 additions & 29 deletions Gruntfile.js
Original file line number Diff line number Diff line change
@@ -269,14 +269,94 @@ module.exports = function(grunt) {
mangle: false,
compress: false
}
},
mangleprops: {
files: {
'tmp/mangleprops.js': ['test/fixtures/src/mangleprops.js']
},
options: {
mangleProperties: true
}
},
mangleprops_withExcept: {
files: {
'tmp/mangleprops_withExcept.js': ['test/fixtures/src/mangleprops.js']
},
options: {
mangle: {
except: ['dontMangleMeVariable']
},
mangleProperties: true
}
},
mangleprops_withExceptionsFiles: {
files: {
'tmp/mangleprops_withExceptionsFiles.js': ['test/fixtures/src/mangleprops.js']
},
options: {
mangle: {
toplevel: true
},
mangleProperties: true,
exceptionsFiles: ['test/fixtures/src/exceptionsfile1.json', 'test/fixtures/src/exceptionsfile2.json']
}
},
mangleprops_withExceptAndExceptionsFiles: {
files: {
'tmp/mangleprops_withExceptAndExceptionsFiles.js': ['test/fixtures/src/mangleprops.js']
},
options: {
mangle: {
toplevel: true,
except: ['dontMangleMeVariable']
},
mangleProperties: true,
exceptionsFiles: ['test/fixtures/src/exceptionsfile1.json', 'test/fixtures/src/exceptionsfile2.json']
}
},
mangleprops_withNameCacheFile: {
files: {
'tmp/mangleprops_withNameCacheFile1.js': ['test/fixtures/src/mangleprops.js'],
'tmp/mangleprops_withNameCacheFile2.js': ['test/fixtures/src/mangleprops_withNameCache.js']
},
options: {
mangle: {
toplevel: true
},
mangleProperties: true,
nameCache: 'tmp/uglify_name_cache.json'
}
},
quotes_single: {
files: {
'tmp/quotes_single.js': ['test/fixtures/src/quotes.js']
},
options: {
quoteStyle: 1
}
},
quotes_double: {
files: {
'tmp/quotes_double.js': ['test/fixtures/src/quotes.js']
},
options: {
quoteStyle: 2
}
},
quotes_original: {
files: {
'tmp/quotes_original.js': ['test/fixtures/src/quotes.js']
},
options: {
quoteStyle: 3
}
}
},

// Unit tests.
nodeunit: {
tests: ['test/*_test.js']
}

});

// task that expects its argument (another task) to fail
@@ -311,34 +391,7 @@ module.exports = function(grunt) {
grunt.registerTask('test', [
'jshint',
'clean',
'uglify:compress',
'uglify:compress_explicit',
'uglify:compress_mangle',
'uglify:compress_mangle_banner',
'uglify:no_src',
'uglify:compress_mangle_except',
'uglify:compress_mangle_beautify',
'uglify:multifile',
'uglify:sourcemap_sources',
'uglify:comments',
'uglify:wrap',
'uglify:maxLineLen',
'uglify:ASCIIOnly',
'uglify:screwIE8',
'uglify:exportAll',
'uglify:enclose',
'uglify:sourcemap_basic',
'uglify:sourcemap_customName',
'uglify:sourcemap_customDir',
'uglify:sourcemap_customRoot',
'uglify:sourcemap_functionName',
'uglify:sourcemap_multiple',
'uglify:sourcemap_multipleFunctionNames',
'uglify:sourcemapin',
'uglify:sourcemap_sources',
'uglify:sourcemapin_sources',
'uglify:expression_json',
'uglify:expression_js',
'uglify',
'nodeunit'
]);

114 changes: 97 additions & 17 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# grunt-contrib-uglify v0.8.1 [![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.9.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.
@@ -46,6 +46,7 @@ Version `3.x` introduced changes to configuring source maps. Accordingly, if you
`sourceMapName` - Accepts a string or function to change the location or name of your map
`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)
`quoteStyle` - Accepts integers `0` (default), `1`, `2`, `3`. Enforce or preserve quotation mark style.

### Options

@@ -54,33 +55,27 @@ This task primarily delegates to [UglifyJS2][], so please consider the [UglifyJS
[UglifyJS2]: https://github.com/mishoo/UglifyJS2
[UglifyJS documentation]: http://lisperator.net/uglifyjs/


#### mangle
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). [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()`. [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()`. [View all options here](https://github.com/mishoo/UglifyJS2#beautifier-options)


###### expression
Type: `Boolean`
Type: `Boolean`
Default: `false`

Parse a single expression, rather than a program (for parsing JSON)
@@ -113,13 +108,13 @@ uglify source is passed as the argument and the return value will be used as the
when there's one source file.

#### sourceMapIncludeSources
Type: `Boolean`
Type: `Boolean`
Default: `false`

Pass this flag if you want to include the content of source files in the source map as sourcesContent property.

###### sourceMapRoot
Type: `String`
Type: `String`
Default: `undefined`

With this option you can customize root URL that browser will use when looking for sources.
@@ -142,13 +137,13 @@ For variables that need to be public `exports` and `global` variables are made a
The value of wrap is the global variable exports will be available as.

#### maxLineLen
Type: `Number`
Type: `Number`
Default: `32000`

Limit the line length in symbols. Pass maxLineLen = 0 to disable this safety feature.

#### ASCIIOnly
Type: `Boolean`
Type: `Boolean`
Default: `false`

Enables to encode non-ASCII characters as \uXXXX.
@@ -184,11 +179,48 @@ 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`
Type: `Boolean`
Default: false

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

#### mangleProperties
Type: `Boolean`
Default: false

Use this flag to turn on object property name mangling.

#### reserveDOMProperties
Type: `Boolean`
Default: false

Use this flag in conjunction with `mangleProperties` to prevent built-in browser object properties from being mangled.

#### exceptionsFiles
Type: `Array`
Default: []

Use this with `mangleProperties` to pass one or more JSON files containing a list of variables and object properties
that should not be mangled. See the [UglifyJS docs](https://www.npmjs.com/package/uglify-js) for more info on the file syntax.

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

A string that is a path to a JSON cache file that uglify will create and use to coordinate symbol mangling between
multiple runs of uglify. Note: this generated file uses the same JSON format as the `exceptionsFiles` files.

#### quoteStyle
Type: `Integer`
Default: `0`

Preserve or enforce quotation mark style.

* `0` will use single or double quotes such as to minimize the number of bytes (prefers double quotes when both will do)
* `1` will always use single quotes
* `2` will always use double quotes
* `3` will preserve original quotation marks

### Usage examples

#### Basic compression
@@ -299,7 +331,6 @@ grunt.initConfig({

Refer to the [UglifyJS SourceMap Documentation](http://lisperator.net/uglifyjs/codegen#source-map) for more information.


#### Turn off console warnings

Specify `drop_console: true` as part of the `compress` options to discard calls to `console.*` functions.
@@ -409,6 +440,7 @@ grunt.initConfig({
}
});
```

#### Compiling all files in a folder dynamically

This configuration will compress and mangle the files dynamically.
@@ -429,10 +461,58 @@ grunt.initConfig({
});
```

#### Turn on object property name mangling

This configuration will turn on object property name mangling, but not mangle built-in browser object properties.
Additionally, variables and object properties listed in the `myExceptionsFile.json` will be mangled. For more info,
on the format of the exception file format please see the [UglifyJS docs](https://www.npmjs.com/package/uglify-js).

```js
// Project configuration.
grunt.initConfig({
uglify: {
options: {
mangleProperties: true,
reserveDOMCache: true,
exceptionsFiles: [ 'myExceptionsFile.json' ]
},
my_target: {
files: {
'dest/output.min.js': ['src/input.js']
}
}
}
});
```

#### Turn on use of name mangling cache

Turn on use of name mangling cache to coordinate mangled symbols between outputted uglify files. uglify will the
generate a JSON cache file with the name provided in the options. Note: this generated file uses the same JSON format
as the `exceptionsFiles` files.

```js
// Project configuration.
grunt.initConfig({
uglify: {
options: {
nameCache: '.tmp/grunt-uglify-cache.json',
},
my_target: {
files: {
'dest/output1.min.js': ['src/input1.js'],
'dest/output2.min.js': ['src/input2.js']
}
}
}
});
```


## Release History

* 2015-02-19   v0.8.1   lock uglify to 2.4.17 due to breaking changes
* 2015-04-07   v0.9.0   added hook into uglify's mangling functionality
* 2015-03-30   v0.8.1   lock uglify to 2.4.17 due to breaking changes
* 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.
@@ -460,4 +540,4 @@ grunt.initConfig({

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

*This file was generated on Mon Mar 30 2015 16:33:34.*
*This file was generated on Tue Apr 07 2015 09:43:05.*
Loading