Is there any tool for combining front-end JS files in NodeJS?
Asked Answered
G

3

8

I have front-end JS files:

-js
  -a.js
  -b.js
  -c.js

and I request http://example.com/js/all.js, I will get a file with all contents of a.js, b.js and c.js.

Is there any library provides such function in NodeJS?

Godwit answered 19/4, 2012 at 5:18 Comment(0)
D
2

You may use simple linux cat to concatenate all scripts into one.

cat ./a.js ./b.js ./c.js > all.js

Also you can execute this command from node.js.

Concatenating scripts to all.js with node.js (on air) not the best way because this will increase the server load.

Disinterested answered 19/4, 2012 at 8:37 Comment(0)
S
2

require.js should offer the functionality you're looking for if the node common.js isn't enough.

Surf answered 19/4, 2012 at 8:45 Comment(0)
H
2

You should check out anvil: https://github.com/arobson/anvil.js

It offers a highly configurable process for preparing a number of front end files, although I can't seem to find an API that can be used directly from your node application.

Hotel answered 18/5, 2012 at 12:2 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.