Command to run terser
on a folder and minify the result in a single file or a new folder.
Install the module with: npm i terser-dir
terser-dir path [options]
--output Specify a file/folder to write the minified code
--config-file Specify a configuration file for Terser
--help Print this list and exit.
$ terser-dir src/js --output .bundle/
$ terser-dir src/js --output .bundle/all.min.js
$ terser-dir demo/files --config-file demo/config.json
$ terser-dir demo/files --output app-test-noconfig.min.js
You can also specify a configuration file in JSON format. The configuration file can define input files, output paths, and debugging options.
{
"input": [
"demo/files/file1.js",
"demo/files/dir1/file2.js"
],
"output": "dist/app-test-config.min.js",
"debug": true
}
The output file can be customized, for example:
app-test-config.min.js
- when using a configuration file.app-test-noconfig.min.js
- when specifying input files directly.