Webpack plugin for minification using oxc-minify
- Types
- ESM
- License
- MIT
- Install Size
- 11.8 kB(4.6 MB)
- Vulns
- 0
- Published
$
npm install oxc-webpack-plugin$
pnpm add oxc-webpack-plugin$
yarn add oxc-webpack-plugin$
bun add oxc-webpack-plugin$
deno add npm:oxc-webpack-plugin$
vlt install oxc-webpack-plugin$
vp add oxc-webpack-pluginoxc-webpack-plugin
A webpack plugin that minifies JavaScript assets using oxc-minify.
Installation
npm install --save-dev oxc-webpack-plugin
Usage
Disable webpack's default minimizer and use OxcMinifyPlugin instead:
import { OxcMinifyPlugin } from "oxc-webpack-plugin";
export default {
mode: "production",
optimization: {
minimize: true,
minimizer: [new OxcMinifyPlugin()],
},
};
By default the plugin minifies any asset matching /\.[cm]?js(\?.*)?$/i and
extracts legal comments (e.g. @license, @preserve, /*!) into a separate
<asset>.LICENSE.txt file with a link comment appended to the asset.
Options
| Option | Type | Default | Description |
|---|---|---|---|
test |
string | RegExp | Array<string | RegExp> |
/\.[cm]?js(\?.*)?$/i |
Match assets to minify. |
include |
string | RegExp | Array<string | RegExp> |
— | Restrict matching to these assets. |
exclude |
string | RegExp | Array<string | RegExp> |
— | Exclude assets from minification. |
extractComments |
boolean |
true |
Extract legal comments into a sibling .LICENSE.txt file. |
minifyOptions |
MinifyOptions |
{} |
Forwarded to oxc-minify. See oxc-minify options. |
extractComments
When true (the default), legal comments are written to
<asset>.LICENSE.txt and a //# sourceMappingURL-style link is appended to
the minified asset. When false, legal comments are dropped entirely.
minifyOptions
Forwarded to oxc-minify. The plugin sets sensible defaults that you can
override:
module— inferred from webpack'sjavascriptModuleasset info and the.mjsextension when not provided.sourcemap— inferred from webpack'sdevtool(enabled when it containssource-map) when not provided.compress.target— inferred fromoutput.environmentwhen not provided (e.g.es2020whendynamicImport/moduleare supported).codegen.legalComments— controlled by theextractCommentsoption above.
License
MIT