rollup-plugin-uglify
    Overview
    Documentation
    Tutorials
    Chat
    Insights
    Code
    Dependencies
    Contributors
    Jobs

rollup-plugin-uglify

Rollup plugin to minify generated bundle

6.0.3  •  Updated 7 months ago  •  by Bogdan Chadkin  •  MIT License

Rollup plugin to minify generated bundle. Uses UglifyJS 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

Note: uglify-js is able to transpile only es5 syntax. If you want to transpile es6+ syntax use terser instead

Install

yarn add rollup-plugin-uglify --dev

Note: this package requires rollup@0.66 and higher

Usage

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

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

Options

uglify(options);

options - uglifyJS API 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:

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):

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

See UglifyJS documentation for further reference.

License

MIT © Bogdan Chadkin

Popularity

Maintenance

Development

Last ver 7 months ago
Created 4 years ago
Last commit 4 months ago
15 days between commits

Technology

Node version: null
5.7K unpacked

Compliance

MIT License
OSI Approved
0 vulnerabilities

Contributors

15 contributors
Bogdan Chadkin
Maintainer, 77 commits, 16 merges
Works at realadvisor
David Knaack
3 commits, 1 PRs
Даниил Пронин
2 commits, 2 PRs
Ratson
2 commits, 2 PRs
Works at (-(-_(-_-)_-)-)
Mateusz Burzyński
2 commits, 2 PRs
Works at livechat
Patrick Arlt
1 commits, 1 PRs
Works at Esri

Tags

rollup
rollup-plugin
uglify
minify
Openbase helps developers choose among and use millions of open-source packages, so they can build amazing products faster.
FacebookTwitterLinkedIn
© 2020 Devstore, Inc.