Preprocessing: ensure dir-index and dir-index-uncat are in sync
rht opened this issue · comments
Preprocessing: Automate the css bundling and injection into dir-index-uncat.html
with gulp-inject / gulp-usemin / gulp-useref
I believe this one's no longer relevant with more recent changes to this repo.
Is this automated now?
My mistake, reopening -- that said, what's the reason maintaining two separate .css files and linking to them from dir-index-uncat.html
instead of in <style>
directly in the html? (Total css file size did go down considerably in recent revisions.)
I think so we can minimize them in the HTML file? We could also, maybe, just embed the CSS then minimize the HTML files themselves on build.
It was probably mostly that the bootstrap code was too much.
There was a lot of Bootstrap code in there before. I'd vote to just embed the minified CSS for those two files in <style>
. The remaining HTML is something like 50 lines.
I'm not sure how to do that in a Go context, but sounds good ...
I think the key here is to remove the need for manual updating of two files
Namely, remove the need for this step from https://github.com/ipfs/dir-index-html#updating:
- Make changes to both dir-index.html and dir-index-uncat.html.
Instead, there should be npm run build
script and clear distinction between
src/
(sources edited in PRs) anddist/
(final artifacts used by go-ipfs)
@lidel the core question is "why DO we carry 2 files".
Here is their difference colordiff -uw dir-index.html dir-index-uncat.html | less -SR
:
Both the inline style and the linked to styles are the same minified .css. It seems... pointless.
I guess (based on partial feedback and git history) in 2015 there were two versions (human-readable source of truth and minified+inlined version for production), but over time only the minified version was updated with changes, making entire setup broken/obsolete.
Cleaning things up and introducing build
script that creates dist/dir-index.html
with inlined and minified CSS from human-readable src/dir-index.html
is how I would fix this. That way only src/dir-index.html
needs to be changed.
I can probably do this. Will have a play around 😊
#40 addresses this, but please note it'll also require updating go-ipfs itself to look for the new file names. (@ribasushi and/or @lidel, is this something you're willing to address in a separate PR?)