Giter Club home page Giter Club logo

webpack-closure-compiler's Introduction

webpack-closure-compiler

Google Closure Compiler plugin for Webpack

Webpack Closure Compiler Plugin

Table of Contents

Why use Closure Compiler instead of UglifyJS?

Closure Compiler is the most advanced JavaScript optimization tool. It generates smallest bundle and emits efficient JavaScript code by doing whole program analysis and optimization, removing closures and inlining function calls, as well as tree-shaking for AMD, CommonJS and ES2015 modules.

Installation

npm i -D webpack-closure-compiler

Usage

Options

compiler: <Object>

A hash of options to pass to google-closure-compiler.

jsCompiler: <Boolean>

Use pure JavaScript version of Closure Compiler (no Java dependency). Note that compilation time will be around 2x slower. Default is false. concurrency and jsCompiler options are mutually exclusive.

concurrency: <Number>

The maximum number of compiler instances to run in parallel, defaults to 1. concurrency and jsCompiler options are mutually exclusive.

test: <RegExp>

Process only files which filename satisfies specified RegExp, defaults to /\.js($|\?)/i.

Example

import path from 'path';
import ClosureCompilerPlugin from 'webpack-closure-compiler';

module.exports = {
    entry: [
        path.join(__dirname, 'app.js')
    ],
    module: {
        loaders: [{
            test: /\.js$/, exclude: /node_modules/,
            loaders: ['babel-loader?optional=runtime&stage=0&cacheDirectory']
        }]
    },
    output: {
        path: path.join(__dirname, '/'),
        filename: 'app.min.js'
    },
    plugins: [
        new ClosureCompilerPlugin({
          compiler: {
            language_in: 'ECMASCRIPT6',
            language_out: 'ECMASCRIPT5',
            compilation_level: 'ADVANCED'
          },
          concurrency: 3,
        })
    ]
};

Contributing

If you've spotted a bug, please, open an issue, and after discussion submit a pull request with a bug fix. If you would like to add a feature or change existing behaviour, open an issue and tell about what exactly you want to change/add.

License

MIT

webpack-closure-compiler's People

Contributors

amilajack avatar dominator008 avatar jscheid avatar lecafard avatar mohsen1 avatar roman01la avatar teppeis avatar trxcllnt 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.