JSPM

@roots/bud-terser

2023.4.1
  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 1179
  • Score
    100M100P100Q110374F
  • License MIT

Adds terser support to Bud

Package Exports

  • @roots/bud-terser
  • @roots/bud-terser/bud/commands
  • @roots/bud-terser/css-minimizer
  • @roots/bud-terser/types

Readme

bud.js

MIT License npm Follow Roots

@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.

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.

KM Digital Carrot WordPress.com Pantheon Worksite Safety Copia Digital