In my application I'm using Gulp to compress all my JS files that are inside the node_modules folder, my question is about performance, it's a bad practice to do this or not?
If you have any suggestions, it will help a lot!
In my application I'm using Gulp to compress all my JS files that are inside the node_modules folder, my question is about performance, it's a bad practice to do this or not?
If you have any suggestions, it will help a lot!
There are a number of ways to work with dependencies of modules installed via NPM.
Compressing every node_modules folder and deploying it, is never a good option. Aliases referencing your direct project to node_modules is not a good practice for several reasons, some of which 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, (myfile.min.js) to deploy to the server.
The good thing about this practice is if you wanted to upgrade some module, you can compare via any merge tool (WinMerge for example) and see what was actually updated or changed in relation to what you are using.
So you can upgrade the modules without fear because they do not directly impact your application unless you choose to consciously upgrade them.
In any case, never delpoy the folder node_modules.