https://github.com/stovmascript/closure-compiler-webpack-plugin
:hocho: Google Closure Compiler plugin for webpack built on the Nailgun JVM.
https://github.com/stovmascript/closure-compiler-webpack-plugin
Last synced: about 1 year ago
JSON representation
:hocho: Google Closure Compiler plugin for webpack built on the Nailgun JVM.
- Host: GitHub
- URL: https://github.com/stovmascript/closure-compiler-webpack-plugin
- Owner: stovmascript
- License: mit
- Created: 2015-09-14T22:51:28.000Z (almost 11 years ago)
- Default Branch: master
- Last Pushed: 2016-08-25T19:11:54.000Z (almost 10 years ago)
- Last Synced: 2024-10-30T07:57:33.949Z (over 1 year ago)
- Language: JavaScript
- Homepage:
- Size: 25.4 KB
- Stars: 8
- Watchers: 3
- Forks: 1
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Closure Compiler plugin for webpack
## Prerequisites
- Java 7 or higher
- Build tools required by node-gyp for [your platform](https://github.com/nodejs/node-gyp#installation)
## Installation
```shell
npm install closure-compiler-webpack-plugin
```
## Example
```javascript
// webpack.config.js
var ClosureCompilerPlugin = require('closure-compiler-webpack-plugin');
module.exports = {
entry: {
core: './core',
home: './home'
},
output: {
filename: '[name].min.js'
},
devtool: 'source-map',
plugins: [
new ClosureCompilerPlugin()
]
};
```
## Options
Use Closure Compiler's flags.
```javascript
// webpack.config.js
...
plugins: [
new ClosureCompilerPlugin({
compilation_level: 'ADVANCED',
create_source_map: false
// Use 'create_source_map: false' to override your webpack
// config. Otherwise, anything you set for this option will be
// ignored in favour of your 'devtool' and filename configuration.
})
]
...
```
For a list of available options:
```shell
java -jar node_modules/closure-compiler-webpack-plugin/node_modules/google-closure-compiler/compiler.jar --help
```
## Shortcomings
Here are some notes, where this package could be improved. Feel free to submit PRs :)
- For some reason, the end event from the Closure Compiler stdout stream for the output JS isn't being triggered. From my investigation, it doesn't seem to be connected to the Nailgun wrapper, but rather a problem of Closure Compiler itself. A pretty ugly hack is used to work around this issue.
- Unlike the built-in UglifyJsPlugin, this one is heavily stream/event based, so there is some state tracking involved to signal when the last file in the compilation was processed. A promise is used, but it still doesn't seem very pretty.