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?
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?
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.
require.js should offer the functionality you're looking for if the node common.js
isn't enough.
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.
© 2022 - 2024 — McMap. All rights reserved.