rollup-plugin-uglify
Advanced tools
Comparing version 0.2.0 to 0.3.1
'use strict'; | ||
function _interopDefault (ex) { return 'default' in ex ? ex['default'] : ex; } | ||
function _interopDefault (ex) { return (ex && (typeof ex === 'object') && 'default' in ex) ? ex['default'] : ex; } | ||
@@ -9,2 +9,3 @@ var uglify = _interopDefault(require('uglify-js')); | ||
var options = arguments.length <= 0 || arguments[0] === undefined ? {} : arguments[0]; | ||
var minifier = arguments.length <= 1 || arguments[1] === undefined ? uglify.minify : arguments[1]; | ||
@@ -22,3 +23,3 @@ return { | ||
var result = uglify.minify(code, options); | ||
var result = minifier(code, options); | ||
@@ -25,0 +26,0 @@ // Strip sourcemaps comment and extra \n |
{ | ||
"name": "rollup-plugin-uglify", | ||
"version": "0.2.0", | ||
"version": "0.3.1", | ||
"description": "Rollup plugin to minify generated bundle", | ||
@@ -11,6 +11,5 @@ "main": "dist/index.js", | ||
"scripts": { | ||
"build": "rollup -c -f cjs -o dist/index.js", | ||
"lint": "eslint src test/*.js", | ||
"pretest": "npm run lint && npm run build", | ||
"pretest": "rollup -c", | ||
"test": "ava", | ||
"posttest": "eslint src test/*.js", | ||
"prepublish": "npm test" | ||
@@ -43,7 +42,7 @@ }, | ||
"babel-preset-es2015-rollup": "^1.1.1", | ||
"eslint": "^1.10.3", | ||
"eslint-config-postcss": "^1.0.0", | ||
"rollup": "^0.25.2", | ||
"eslint": "^2.0.0", | ||
"eslint-config-postcss": "^2.0.0", | ||
"rollup": "^0.25.3", | ||
"rollup-plugin-babel": "^2.3.9" | ||
} | ||
} |
@@ -28,4 +28,20 @@ # rollup-plugin-uglify [![Travis Build Status][travis-img]][travis] | ||
## Warning | ||
[UglifyJS](https://github.com/mishoo/UglifyJS2), which this plugin is based on, does not support the ES2015 module syntax. Thus using this plugin with Rollup's default bundle format (`'es6'`) will not work and error out. | ||
To work around this you can tell `rollup-plugin-uglify` to use the UglifyJS [harmony branch](https://github.com/mishoo/UglifyJS2/tree/harmony) by passing its `minify` function to minify your code. | ||
```js | ||
import { rollup } from 'rollup'; | ||
import uglify from 'rollup-plugin-uglify'; | ||
import { minify } from 'uglify-js'; | ||
rollup({ | ||
entry: 'main.js', | ||
plugins: [ | ||
uglify({}, minify) | ||
] | ||
}); | ||
``` | ||
# License | ||
MIT © [Bogdan Chadkin](mailto:trysound@yandex.ru) |
import uglify from 'uglify-js'; | ||
export default function (options = {}) { | ||
export default function (options = {}, minifier = uglify.minify) { | ||
return { | ||
@@ -15,3 +15,3 @@ transformBundle(code) { | ||
const result = uglify.minify(code, options); | ||
const result = minifier(code, options); | ||
@@ -18,0 +18,0 @@ // Strip sourcemaps comment and extra \n |
Sorry, the diff of this file is not supported yet
5277
46
47