A CLI module that allows you to work with multiple files at once using the glob pattern in the terser cli.
This resolves issues #544 and #866 in terser
.
To learn how to use the Terser CLI, follow these links: https://terser.org/docs/cli-usage
Terser It's the same as how to use CLI, but there are a few differences in this module.
- You can use the
glob
pattern for file paths (paths must be enclosed in quotes). You can also specify each file individually without using the glob pattern. - If an output path is set, it must be a directory. We currently do not support combining multiple files into one.
# via npm
$ npm i -D terser-glob
# via yarn
$ yarn add -D terser-glob
# via pnpm
$ pnpm i -D terser-glob
The terser
package is included as a dependency in terser-glob
, so you don't need to install it separately.
Just replace the existing terser
command with terser-glob
!
terser-glob filePathOrGlobPattern [terser-cli-options]
# Example 1
$ terser-glob dist/index.js dist/hello.js dist/world.js --mangle
# Example 2
$ terser-glob "dist/*.js" dist/hello.js
# Example 3
$ terser-glob "dist/**/*.js" --ie8 --mangle --output result/
# Example 4
$ terser-glob "dist/abc/*.js" "dist/def/*" --config-file terser.config.json
Usage: terser-glob [options] [files...]
Options:
-V, --version output the version number
-p, --parse <options> Specify parser options.
-c, --compress [options] Enable compressor/specify compressor options.
-m, --mangle [options] Mangle names/specify mangler options.
--mangle-props [options] Mangle properties/specify mangler options.
-f, --format [options] Format options.
-b, --beautify [options] Alias for --format.
-o, --output <file> Output file (default STDOUT).
--comments [filter] Preserve copyright comments in the output.
--config-file <file> Read minify() options from JSON file.
--ecma <version> Specify ECMAScript release: 5, 2015, 2016 or 2017...
-e, --enclose [arg[,...][:value[,...]]] Embed output in a big function with configurable arguments and values.
--ie8 Support non-standard Internet Explorer 8.
--keep-classnames Do not mangle/drop class names.
--keep-fnames Do not mangle/drop function names. Useful for code relying on Function.prototype.name.
--module Input is an ES6 module
--name-cache <file> File to hold mangled name mappings.
--safari10 Support non-standard Safari 10.
--source-map [options] Enable source map/specify source map options.
--toplevel Compress and/or mangle variables in toplevel scope.
-h, --help output usage information
Anyone can contribute to the project by reporting new issues or submitting a pull request. For more information, please see CONTRIBUTING.md.
Please see the LICENSE file for more information about project owners, usage rights, and more.