jeudi 19 mars 2015

How should I serve static dependencies in ExpressJS?


Normally, I copy libraries like jQuery into the js/lib folder of a web project so that they can be used by the client.


I was thinking that if I'm already using npm for package management, I could just skip this step. I did this instead:


npm install jquery --save


and then in my server code:



app.use('js/lib/jquery.min.js', express.static('node_modules/jquery/dist/jquery.min.js'));


Is this approach any better? It seems more DRY not to have two different folders for dependencies, but it also feels hacky and less transparent.





Aucun commentaire:

Enregistrer un commentaire