@roots/bud-terser
TypeScript icon, indicating that this package has built-in type declarations

6.14.1 • Public • Published

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

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.

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

Package Sidebar

Install

npm i @roots/bud-terser

Weekly Downloads

1,331

Version

6.14.1

License

MIT

Unpacked Size

25.4 kB

Total Files

10

Last publish

Collaborators

  • qwp6t
  • swalkinshaw
  • retlehs
  • log1x
  • kellymears