# rollup-plugin-uglify

> Rollup plugin to minify generated bundle

Latest version **6.0.4** (published 2019-12-11) · MIT license · 0 weekly downloads

## Install

```sh
npm install rollup-plugin-uglify
pnpm add rollup-plugin-uglify
yarn add rollup-plugin-uglify
bun add rollup-plugin-uglify
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 6.0.4 |
| Published | 2019-12-11 |
| First published | 2015-12-31 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 4 |
| Unpacked size | 5.5 KB |
| Known vulnerabilities | 0 (+2 in 1 direct dependencies) |
| Install scripts | no |
| GitHub stars | 260 |
| Author | Bogdan Chadkin |
| Maintainers | trysound |
| Keywords | rollup, rollup-plugin, uglify, minify |

## Links

- npm: https://www.npmjs.com/package/rollup-plugin-uglify
- Repository: https://github.com/TrySound/rollup-plugin-uglify
- npm.io page: https://npm.io/package/rollup-plugin-uglify

## Dependencies (4)

- [uglify-js](https://npm.io/package/uglify-js.md) ^3.4.9
- [jest-worker](https://npm.io/package/jest-worker.md) ^24.0.0
- [@babel/code-frame](https://npm.io/package/@babel/code-frame.md) ^7.0.0
- [serialize-javascript](https://npm.io/package/serialize-javascript.md) ^2.1.2

## Alternatives

- [raw-loader](https://npm.io/package/raw-loader.md) — 4.3M weekly downloads
- [plop](https://npm.io/package/plop.md) — 1.4M weekly downloads
- [webpack-deadcode-plugin](https://npm.io/package/webpack-deadcode-plugin.md) — 80.3K weekly downloads
- [@storybook/preact-vite](https://npm.io/package/@storybook/preact-vite.md) — 54.2K weekly downloads
- [vite-plugin-transform](https://npm.io/package/vite-plugin-transform.md) — 2.4K weekly downloads

## Recent versions

- 6.0.4 (latest) — 2019-12-11
- 6.0.3 — 2019-08-30
- 6.0.2 — 2019-01-25
- 6.0.1 — 2019-01-11
- 6.0.0 — 2018-09-16
- 5.0.2 — 2018-08-30
- 5.0.1 — 2018-08-30
- 5.0.0 — 2018-08-30
- 4.0.0 — 2018-05-19
- 3.0.0 — 2018-01-20
- 2.0.1 — 2017-05-21
- 2.0.0 — 2017-05-19
- 1.0.2 — 2017-04-20
- 1.0.1 — 2016-06-23
- 1.0.0 — 2016-06-12
- … 3 more at https://npm.io/package/rollup-plugin-uglify/versions

## README

# rollup-plugin-uglify [![Travis Build Status][travis-img]][travis]

[travis-img]: https://travis-ci.org/TrySound/rollup-plugin-uglify.svg
[travis]: https://travis-ci.org/TrySound/rollup-plugin-uglify

[Rollup](https://github.com/rollup/rollup) plugin to minify generated bundle. Uses [UglifyJS](https://github.com/mishoo/UglifyJS2) under the hood. There are a few improvements over native uglify:

* uglify is run in worker for every chunk
* errors are displayed with [babel code frame](https://babeljs.io/docs/en/next/babel-code-frame.html)

_Note: uglify-js is able to transpile only es5 syntax. If you want to transpile es6+ syntax use [terser](https://github.com/TrySound/rollup-plugin-terser) instead_

## Install

```sh
yarn add rollup-plugin-uglify --dev
```

*Note: this package requires rollup@0.66 and higher*

## Usage

```js
import { rollup } from "rollup";
import { uglify } from "rollup-plugin-uglify";

rollup({
  input: "main.js",
  plugins: [uglify()]
});
```

## Options

```js
uglify(options);
```

`options` - [uglifyJS API options](https://github.com/mishoo/UglifyJS2/blob/master/README.md#minify-options)

`options.sourcemap: boolean`

Generates source maps and passes them to rollup. Defaults to `true`.

`options.numWorkers: number`

Amount of workers to spawn. Defaults to the number of CPUs minus 1.


## Examples

### Comments

If you'd like to preserve comments (for licensing for example), then you can specify a function to do this like so:

```js
uglify({
  output: {
    comments: function(node, comment) {
      if (comment.type === "comment2") {
        // multiline comment
        return /@preserve|@license|@cc_on/i.test(comment.value);
      }
      return false;
    }
  }
});
```

Alternatively, you can also choose to keep all comments (e.g. if a licensing header has already been prepended by a previous rollup plugin):

```js
uglify({
  output: {
    comments: "all"
  }
});
```

See [UglifyJS documentation](https://github.com/mishoo/UglifyJS2/blob/master/README.md) for further reference.

# License

MIT © [Bogdan Chadkin](mailto:trysound@yandex.ru)

---
_Source: https://npm.io/package/rollup-plugin-uglify · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
