@semibold/closure-compiler-plugin

4.0.0 • Public • Published

Closure-Compiler-Plugin

Changelog

Installation

npm i -D @semibold/closure-compiler-plugin

Requirements

While there's JavaScript version of Closure Compiler, the original compiler is written in Java and thus Java version is more complete and performs better in terms of JavaScript code optimizations and compilation speed. If you want to use Java-based compiler, make sure you have installed Java SDK.

Usage

Options

compiler: <Object>

A hash of options to pass to google-closure-compiler(Flags and Options).

You can optionally specify a path to your own version of the compiler.jar if the version provided by the plugin isn't working for you. See example below for optional parameter.

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

The maximum number of compiler instances to run in parallel, defaults to 1.

test: <RegExp | RegExp[]>

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

Example

const path = require("path");
const ClosureCompilerPlugin = require("@semibold/closure-compiler-plugin");

module.exports = {
    entry: path.join(__dirname, "app.js"),
    output: {
        path: path.join(__dirname, "dist"),
        filename: "[name].min.js",
    },
    mode: "production",
    devtool: "source-map",
    plugins: [
        new ClosureCompilerPlugin({
            compiler: {
                jar: "path/to/your/custom/compiler.jar", // Optional
                language_in: "ECMASCRIPT6",
                language_out: "ECMASCRIPT5",
                compilation_level: "ADVANCED",
                isolation_mode: "IIFE",
                create_source_map: true,
                externs: [path.join(__dirname, "externs.js")],
            },
        }),
    ],
    optimization: {
        minimize: false,
    },
};

FAQ

Package Sidebar

Install

npm i @semibold/closure-compiler-plugin

Weekly Downloads

0

Version

4.0.0

License

MIT

Unpacked Size

16.7 kB

Total Files

16

Last publish

Collaborators

  • aqours