GithubHelp home page GithubHelp logo

lguzzon-js / rollup-plugin-uglify Goto Github PK

View Code? Open in Web Editor NEW

This project forked from trysound/rollup-plugin-uglify

0.0 1.0 0.0 52 KB

Rollup plugin to minify generated bundle

License: MIT License

JavaScript 100.00%

rollup-plugin-uglify's Introduction

rollup-plugin-uglify Travis Build Status

Rollup plugin to minify generated bundle.

Install

npm i rollup-plugin-uglify -D

Usage

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

rollup({
    entry: 'main.js',
    plugins: [
        uglify()
    ]
});

Options

uglify(options, minifier)

options – default: {}, type: object. UglifyJS API options

minifier – default: require('uglify-js').minify, type: function. Module to use as a minifier. You can use other versions (or forks) of UglifyJS instead default one.

Warning

UglifyJS, which this plugin is based on, does not support the ES2015 module syntax. Thus using this plugin with Rollup's default bundle format ('es') will not work and error out. To work around this you can tell rollup-plugin-uglify to use the UglifyJS unstable es version by passing its minify function to minify your code.

import { rollup } from 'rollup';
import uglify from 'rollup-plugin-uglify';
import { minify } from 'uglify-es';

rollup({
    entry: 'main.js',
    plugins: [
        uglify({}, minify)
    ]
});

To install the experimental version of UglifyJS:

npm i uglify-es -D

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) {
        var text = comment.value;
        var type = comment.type;
        if (type == "comment2") {
            // multiline comment
            return /@preserve|@license|@cc_on/i.test(text);
        }
    }
  }
});

See UglifyJS documentation for further reference.

License

MIT © Bogdan Chadkin

rollup-plugin-uglify's People

Contributors

anmonteiro avatar bfred-it avatar davidkna avatar grawl avatar jltrv avatar lguzzon avatar patrickarlt avatar ratson avatar trysound avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.