@roots/bud-terser
Adds terser support to Bud
Installation
Install @roots/bud-terser to your project.
Yarn:
yarn add @roots/bud-terser --dev
npm:
npm install @roots/bud-terser --save-dev
The @roots/bud-terser extension is pre-installed and enabled by default for production builds.
Options
Option | type | Default |
---|---|---|
minify |
TerserWebpackPlugin.MinimizerImplementation<TerserOptions> |
TerserWebpackPlugin.terserMinify |
include |
TerserWebpackPlugin.BasePluginOptions['include'] |
undefined |
exclude |
TerserWebpackPlugin.BasePluginOptions['exclude'] |
undefined |
extractComments |
TerserWebpackPlugin.BasePluginOptions['extractComments'] |
false |
parallel |
TerserWebpackPlugin.BasePluginOptions['parallel'] |
true |
terserOptions |
TerserWebpackPlugin.TerserOptions |
[object] |
- When @roots/bud-swc is installed the swc minifier function will be used.
- When @roots/bud-esbuild is installed the esbuild minifier function will be used.
API
bud.minify.js.getInclude
Get the value of include
bud.minify.js.getInclude()
Set the value of include
bud.minify.js.setInclude(/.*/)
bud.minify.js.exclude
Get the value of exclude
bud.minify.js.getExclude()
Set the value of exclude
bud.minify.js.setExclude(/.*/)
bud.minify.js.minify
Get the value of minify
.
bud.minify.js.getMinify()
Set the value of minify
. Since the value is a function you must wrap it in a callback.
const dubiousMinifier = async (input: unknown) => ({
code: Object.values(input).join(`\n`).replace(/\/\//g, `// 💸`),
})
bud.minify.js.setMinify(() => dubiousMinifier)
bud.minify.js.parallel
Get the value of parallel
.
bud.minify.js.getParallel()
Set the value of parallel
.
bud.minify.js.setParallel(true)
bud.minify.js.extractComments
Get the value of extractComments
.
bud.minify.js.getExtractComments()
Set the value of extractComments
.
bud.minify.js.setExtractComments(true)
bud.minify.js.terserOptions
Get the value of terserOptions
.
bud.minify.js.getTerserOptions()
Set the value of terserOptions
.
bud.minify.js.setTerserOptions(options => ({
...options,
mangle: false,
}))
bud.minify.js.dropComments
Drop comments from output:
export default async bud => {
bud.minify.js.dropComments()
}
bud.minify.js.dropConsole
Drop console.*
statements from output.
export default async bud => {
bud.minify.js.dropConsole()
}
Contributing
Contributions are welcome from everyone.
We have contribution guidelines to help you get started.
License
@roots/bud-terser is licensed under MIT.
Community
Keep track of development and community news.
- Join us on Roots Slack by becoming a GitHub sponsor
- Participate on the Roots Discourse
- Follow @rootswp on Twitter
- Read and subscribe to the Roots Blog
- Subscribe to the Roots Newsletter
Sponsors
Bud is an open source project and completely free to use.
However, the amount of effort needed to maintain and develop new features and projects within the Roots ecosystem is not sustainable without proper financial backing. If you have the capability, please consider sponsoring Roots.