Reputation: 596
Sorry that I'm not able to define a title that brings my question to a point. But I will try to explain my problem here:
We're using Grunt in our JavaScript projects to compile Sass files to CSS and to browserify and minify our JavaScript modules.
The Sass and JavaScript sources are located in multiple folders (one per app-module) with the following folder structure:
src/
styles/
base.scss
style.scss
js/
module1.js
module2.js
app.js
The Grunt tasks compiles this file into this structure:
dist/
styles/
style.css
js/
app.js
All files under dist
are ignored by Git.
When we deploy our application, we create incremental updates which is basically a git diff --name-only
to get a list of files that changed.
Here comes my problem: when I deploy the application, I will have to build all JavaScript and Sass files. As the compiled files are outside of Git, I have no clue which of these files have changed (compared to the latest release) or not.
The only solution that comes into my mind is adding the compiled CSS and JavaScript file to Git, too. But then we will have to struggle with merge conflicts in these files.
Any ideas or experiences how to optimize this workflow?
Update 2017-09-19: I've changed the title to be more accurate as what I was searching for is a workflow to build incremental updates on a JavaScript-project that uses Grunt and Git.
Upvotes: 0
Views: 95
Reputation: 596
Based on the answer by @Dunno, the workflow for creating updates is now as follows:
Incremental updates
HEAD
into temporary directory with the help of git-archive
grunt
HEAD
(HEAD^
) into temporary directory with the help of git-archive
grunt
git-diff --no-index
(which allows to compare files in directories without an index)tar
and gzip
, ignore all files in src
foldersFull updates
HEAD
into temporary directory with the help of git-archive
grunt
tar
and gzip
, ignore all files in src
foldersThe usage of git-diff --no-index
was really the life-saver, as neither diff
nor rsync
were able to report changes in the way I need them.
Upvotes: 0
Reputation: 3684
You shouldn't keep compiled files in your repository - it doesn't make any sense to do so. It only causes merge conflicts and makes a mess in commit history. You should track all neccessary source and configuration files, so that anyone can build easily from any point in history. If you do that, then your problem comes down to
git checkout newVersion
<build>
git checkout oldVersion
<build>
diff newBuild oldBuild
Upvotes: 2