Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Should I commit css and js generated by laravel mix?

I started using laravel mix, and there's huge files generated by it. Should I commit those to the repo? What are the advantages and cons of both ways?

like image 417
zbyshekh Avatar asked Mar 06 '23 07:03

zbyshekh


2 Answers

You should not add anything to the repo that can be generated at any time, for example after pull. A clear well known example that can be added to your predicament, is node_modules. They can always be generated by npm install, therefore it should always be added to .gitignore

like image 84
Constantin Chirila Avatar answered Mar 29 '23 06:03

Constantin Chirila


Reasons you should commit these files:

  1. No need to install node modules bloat on the production server (less security risks);
  2. Much faster deployment. Just pull your changes and everything is there;
  3. You don't need to keep node/npm versions in sync so compiled scripts are always identical on your machine as on production;

Reason why you should not commit:

  1. Less files in version control (nicer diff/log);
  2. You don't need to remember to compile scripts for production before deployment;
  3. No merging issues (if you work in a team) for the compiled files.

If I'm working alone on a project and don't do very frequent deployments, I'd choose to commit these files.

If you have a decent deployment pipeline which can build these files on-the-fly when you need to deploy, then I would definitely not commit them.

like image 21
Mārtiņš Briedis Avatar answered Mar 29 '23 07:03

Mārtiņš Briedis