A webpack plugin integrating Google Closure Compiler and Closure Library for JavaScript optimization and transpilation. Version 2.6.1 (webpack 4 branch) requires google-closure-compiler >=20200830.0.0 and webpack 4.x. Offers three platforms (native, Java, JavaScript) and two modes (STANDARD for minification/transpilation, AGGRESSIVE_BUNDLE for advanced module hoisting and optimization). Unlike TerserPlugin or Babel, it provides full Closure Compiler optimizations including dead code elimination, type checking, and cross-module analysis. Not compatible with webpack 5.
npm install closure-webpack-pluginVerified import paths — ran on the pinned version, not inferred.
Basic webpack config using closure-webpack-plugin as the minifier with JavaScript platform, STANDARD mode, and debug flags.
Use webpack 4 or switch to an alternative plugin for webpack 5.
Remove these flags from the compiler options object. They are overridden internally.
Use lowercase strings as above. The plugin may also accept uppercase but it's not guaranteed.
Ensure modules with side-effects are separated into different chunks or mark them with sideEffects: false in package.json.
Set childCompilations: true or a custom function if child compilations need closure optimization.
Use `const ClosurePlugin = require('closure-webpack-plugin');`Run `npm install --save-dev google-closure-compiler`
Downgrade to webpack 4.x, or use an alternative plugin (e.g., terser-webpack-plugin) for webpack 5.