Mark
Mark

Reputation: 33671

Uglify directory

Rather than adding code and files to the uglify script individually, is there any way to tell uglify to grab an entire dir, and output into 1 script.js file?

Upvotes: 14

Views: 10469

Answers (5)

Juraj
Juraj

Reputation: 6648

You can use uglifyjs-folder module for that. It also supports processing them individually (no merging together).

https://github.com/ionutvmi/uglifyjs-folder
https://www.npmjs.com/package/uglifyjs-folder

Upvotes: 3

mishoo
mishoo

Reputation: 2419

find /path/to/dir -name "*.js" | xargs cat | uglifyjs -o > result.js

Note that the load order of your scripts might be important. The above could therefore fail (as it just dumps the files in whatever order find happens to return them). I would suggest you to write a small shell script customized for your application.

Upvotes: 9

Samuel
Samuel

Reputation: 1667

I'm late to the party, but I found Igneous to be very convenient. It does what it says without imposing additional constraints or philosphies.

Upvotes: 0

balupton
balupton

Reputation: 48757

https://github.com/balupton/buildr.npm may also be helpful

The (Java|Coffee)Script and (CSS|Less) (Builder|Bundler|Packer|Minifier|Merger|Checker)

Upvotes: 1

ase
ase

Reputation: 13489

cat * | uglifyjs -o script.js

If by uglifyjs you mean https://github.com/mishoo/UglifyJS this works! Without an input file uglifyjs will read from STDIN.

Upvotes: 15

Related Questions