https://github.com/henrhie/swc-webpack-minifier
minify browser javascript code with swc
https://github.com/henrhie/swc-webpack-minifier
Last synced: 3 months ago
JSON representation
minify browser javascript code with swc
- Host: GitHub
- URL: https://github.com/henrhie/swc-webpack-minifier
- Owner: henrhie
- License: mit
- Created: 2022-03-27T18:56:54.000Z (about 3 years ago)
- Default Branch: master
- Last Pushed: 2022-03-28T15:11:12.000Z (about 3 years ago)
- Last Synced: 2025-01-10T00:14:38.928Z (5 months ago)
- Language: JavaScript
- Homepage: https://www.npmjs.com/package/swc-webpack-minifier
- Size: 38.1 KB
- Stars: 2
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# swc-webpack-minifier - webpack plugin
Speed up ⚡⚡⚡ webpack build by delegating javascript minification to [swc](https://swc.rs/)
swc-webpack-minifier is an attempt to explore the various ways developer experience can be greatly improved upon without compromising quality of code. Under the hood, this webpack plugin utilizes the sheer speed of the swc minifier (written in Rust) to generate small and optimized bundles for browser javascript environments.
## Install
```bash
npm install swc-webpack-minifier --save-dev
```
## Usage
`webpack.config.js`
```js
module.exports = {
...
optimization: {
minimizer: [
new SwcWebpackMinifier({
...transformationOptions
}),
],
},
devtool: 'source-map',
};
``````js
type transformationOptions = swc.JsMinifyOptions & {
include?: Filter | Filter[];
exclude?: Filter | Filter[];
}
```
[swc.JsMinifyOptions](https://swc.rs/docs/configuration/minification)`index.js`
```js
function foo(x) {
if (x) {
return JSON.stringify(x);
}
return 'default string';
}foo(55);
````dist/main.bundle.js`
```js
(()=>{var __webpack_exports__={};function foo(x){if(x){return JSON.stringify(x)}return"default string"}foo(55)})()
//# sourceMappingURL=main.bundle.js.map
```## Benchmarks
Go to https://github.com/privatenumber/minification-benchmarks to see how the swc minifier stacks up against other popular options in terms of speed and bundle size.
## License
[MIT](https://choosealicense.com/licenses/mit/)