Npm scripts - how to minify files from a folder and save them into another?

425 views Asked by At

I'm using npm scripts to compile and minify sass and potentionally javascript files. However, I'm looking for at way to specify a source folder of *.js files and have them minified and saved in a destination folder individually - (flattened, not concatenated) each as *.min.js.

I have tried with npm terser, but it doesn't seem to be able to with with a source folder, only single files, nor does it seem to be able to minify the files individually.

So, what I'm looking for:

Src/
 |__main.js
 |__menu.js
 |__etc...
Dist/
 |__main.min.js
 |__menu.min.js
 |__...

Which npm package should I use for this?

1

There are 1 answers

0
Meek On BEST ANSWER

So, it seems that the package Terser folder can do just this...