1
In my application I am using Gulp to compress all my files JS inside the case node_modules, my question is on performance, it is a bad practice to do this or not?
If you have any suggestions will help a lot!
1
In my application I am using Gulp to compress all my files JS inside the case node_modules, my question is on performance, it is a bad practice to do this or not?
If you have any suggestions will help a lot!
1
There are several ways to work with the dependencies of modules installed via NPM.
Compressing all node_modules and deploying it is never a good option. Making reference in your direct project to node_modules is not a good practice for several reasons, some of them are:
A good practice is.
You have the following structure (for example)
node_modules/
----- angularjs/
---------- angular.js
---------- angular.min.js
---------- vários outros arquivos
Your app here
app/
----- js/
---------- libs/
--------------- develop/
-------------------- angular.js (aqui é o módulo do angular instalado via NPM sem ser minificadom usado geralmente para debug ou olhar o código para entender o que a library faz)
dist /
(dentro da pasta dist que seus arquivos vão estar todos minificados, otimizados e compactados)
You can make this copy via GULP, GRUNT or even manually if you prefer.
So also use GULP or GRUNT to minify the js files, (meuarquivojs.min.js) to deploy to the server.
The good thing about this practice is if you wanted to update some module, you can compare via any merge tool (Winmerge for example) and see what has actually been updated or changed with respect to what you are using.
So you can update the modules without fear, as they do not impact directly on your application unless you choose to update them consciously.
Anyway, never delpoy the node_modules folder.
Browser other questions tagged node.js gulp
You are not signed in. Login or sign up in order to post.
Reading a compressed js file is always faster. Now, you will serve all the files of your Node modules along with your application? The interesting thing is to minify the production files. I do not know if compacting the development ones would bring any benefit, except for the execution of their tasks...
– Caio Felipe Pereira
One question, why are you compressing node_modules files? Question of deploy? Modules you install via NPM (which are inside the node_modules folder) should not be touched.
– Erick Gallani
I’m not moving, it’s a question of structure. The module folder is outside the folder that goes to production (public) and I need to bring all the Javascript dependencies inside it, an alternative that I thought is to copy everything using Gulp.
– Carlos Pereira