Npm脚本 – 如何压缩一个文件夹中的文件并将它们保存到另一个文件夹中?

huangapple go评论70阅读模式
英文:

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

问题

我正在使用npm脚本来编译和压缩sass和可能的javascript文件。但是,我正在寻找一种指定*.js文件的源文件夹并将它们逐个(不合并)压缩并保存在目标文件夹中的方法,每个文件保存为*.min.js

我尝试过使用npm terser,但似乎不能处理源文件夹,只能处理单个文件,而且似乎也不能逐个压缩文件。

所以,我正在寻找:

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

我应该使用哪个npm包来实现这个目标?

英文:

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

得分: -1

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

英文:

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

huangapple
  • 本文由 发表于 2023年7月13日 18:31:26
  • 转载请务必保留本文链接:https://go.coder-hub.com/76678384.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定