Package Exports
- @roots/bud-terser
- @roots/bud-terser/bud/commands
- @roots/bud-terser/css-minimizer
- @roots/bud-terser/types
Readme
@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 extension requires zero configuration, but you can customize its options if needed.
Here are some configuration examples for different use cases:
Remove console.log statements and comments from the production build
export default async (bud) => {
bud.terser.dropConsole().dropComments();
};
Keep comments in the minified output
export default async (bud) => {
bud.terser.dropComments(false);
};
Disable mangling of variable names
export default async (bud) => {
bud.terser.set("terserOptions.mangle", false);
};
Customize compression options
export default async (bud) => {
bud.terser.set("terserOptions.compress", {
drop_console: true,
drop_debugger: false,
defaults: true,
unused: true,
});
};
Use a custom regular expression for inclusion/exclusion of files
export default async (bud) => {
bud.terser.set("include", /src\/js\/.*\.js$/);
bud.terser.set("exclude", /node_modules/);
};
To apply any of these configurations, add the respective code snippet to your bud.config.js file.
The @roots/bud-terser extension is included in the bud.js framework and is enabled by default for production builds.
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.