w3c / midgard

Dashboard for the dwellers of our world
MIT License
13 stars 16 forks source link

Actually... let's keep generated assets under version control? #24

Closed tripu closed 5 years ago

tripu commented 5 years ago

After following @dontcallmedom's suggestion on #23 (ie, do not include JS or CSS generated files in Git), I re-deployed, and realised that there's an advantage to having those files under version control: one does not need to install all devDependencies in production to generate those files.

In this case, one cannot do npm install --production and then npm run build — the latter fails.

If those files were included in the build, npm install --production is possible, and we avoid the overhead/risk of devDependencies in production servers.

Practical example: visit Midgard in Labs and open the JS console: there are warnings coming from watchify. But watchify is not needed in production.

(node) warning: possible EventEmitter memory leak detected. 11 listeners added. Use emitter.setMaxListeners() to increase limit.
dontcallmedom commented 5 years ago

the reason I don't like generated files in the version control:

Maybe they could be generated automatically in a separate "prod" branch (or this could be done as an intermediary scripted step in a separate space on the target server)

Anyway, I won't die on that hill, so I'll let you assess the trade-off - at least for midgard, it's not like we had so much active development on it.

tripu commented 5 years ago

Same here: not a big deal either way. I'm just interested in finding out what's the best approach, in general. We face the same trade-offs in other projects.

Solutions I see:

They create useless conflicts if you work across several branches in parallel

Those conflicts are the easiest to resolve: you resolve conflicts in source files first (if there are any), then rebuild, and whatever generated files that produces, those are “the good ones”, right? One cannot combine changes by hand in compressed, minified or uglified files anyway.

They create noise in reviewing diffs

GH excludes many generated files automatically from diffs. It seems that when that heuristic fails (eg) we can force it with a .gitattributes file (eg, a line public/js/app.js linguist-generated=true). Not sure if there's a similar mechanism in Git, though.

tripu commented 5 years ago

Deferring to @dontcallmedom's opinion on this, since he and/or others are inheriting maintenance of this project.