mettjus
mettjus

Reputation: 2988

How to manage version control and production deployments for compiled assets with Git and Grunt/Sass/Composer?

I'm building an app in PHP + HTML + CSS + JS. This is the setup:

When I deploy to staging/production I git clone (or git pull) the needed branch (develop or master) from the online Git repo.

I used to track almost everything with Git, including compiled CSS and installed PHP modules (via Composer), so that it was easy to deploy: I just had to pull from the online repo end everything was done.

But I feel tracking all this stuff in Git is not good as I think I should just track the source files (SCSS for CSS, composer.json/composer.lock for PHP modules).

Now my questions are:

Any advice/suggestion would be greatly appreciated!

Upvotes: 2

Views: 615

Answers (1)

Michael Durrant
Michael Durrant

Reputation: 96544

One answer (that we use) is to do your asset compilation on a continuous integration machine. We consider this to be our staging environment.
From here we copy the compiled files to production (i.e. we don't generate them in production as well).

In some cases you may want to allow developers to compile locally (if the framework requires it for development) but ignore those files/directories when pushing to a remote. This is essentially the process we use for our Ruby on Rails gem files that are handled by bundler. A little different from css/js assets but involving similar concepts of compiled or changed files.

Upvotes: 2

Related Questions