Macros and Functions
Run the terser minifier.
name = "out.min",
srcs = "input.js",
config_file = "terser_config.json",
Note that the
name attribute determines what the resulting files will be called.
So the example above will output
sourcemap defaults to
If the input is a directory, then the output will also be a directory, named after the
Note that this rule is NOT recursive. It assumes a flat file structure. Passing in a folder with nested folder will result in an empty output directory.
A unique name for this target.
Label pointing to the linked node_modules target where the
terser is linked, e.g.
terser must be linked into the node_modules supplied.
File(s) to minify.
.js files, a rule producing
.js files as its default output, or a rule producing a directory of
If multiple files are passed, terser will bundle them together.
Runtime dependencies to include in binaries/tests that depend on this target.
The transitive npm dependencies, transitive sources, default outputs and runfiles of targets in the
are added to the runfiles of this target. They should appear in the '*.runfiles' area of any executable which has
a runtime dependency on this target.
If this list contains linked npm packages, npm package store targets or other targets that provide
NpmPackageStoreInfo providers are gathered from
JsInfo. This is done directly from
npm_package_store_deps field of these. For linked npm package targets, the underlying
npm_package_store target(s) that back the links is used. Gathered
providers are propagated to the direct dependencies of downstream linked
NB: Linked npm package targets that are "dev" dependencies do not forward their underlying
npm_package_store target(s) through
npm_package_store_deps and will therefore not be
propagated to the direct dependencies of downstream linked
npm_package targets. npm packages
that come in from
npm_translate_lock are considered "dev" dependencies if they are have
dev: true set in the pnpm lock file. This should be all packages that are only listed as
"devDependencies" in all
package.json files within the pnpm workspace. This behavior is
intentional to mimic how
devDependencies work in published npm packages.
Whether to produce a .js.map output
A JSON file containing Terser minify() options.
This is the file you would pass to the --config-file argument in terser's CLI.
https://github.com/terser-js/terser#minify-options documents the content of the file.
Bazel will make a copy of your config file, treating it as a template.
Run bazel with
--subcommands to see the path to the copied file.
If you use the magic strings
"bazel_no_debug", these will be
false respecting the value of the
--compilation_mode=dbg bazel flag.
Will disable the
arrows compression setting when debugging.
config_file isn't supplied, Bazel will use a default config file.
Configure terser to produce more readable output.
Instead of setting this attribute, consider using debugging compilation mode instead bazel build --compilation_mode=dbg //my/terser:target so that it only affects the current build.
Additional command line arguments to pass to terser.
Terser only parses minify() args from the config file so additional arguments such as
be passed to the rule using this attribute. See https://github.com/terser/terser#command-line-usage for the
full list of terser CLI options.
Other common arguments such as