Skip to content
This repository has been archived by the owner on Mar 22, 2022. It is now read-only.

feat: Build script #40

Merged
merged 14 commits into from
Jul 27, 2020
Merged

feat: Build script #40

merged 14 commits into from
Jul 27, 2020

Conversation

jessicaschilling
Copy link
Contributor

@jessicaschilling jessicaschilling commented Jul 24, 2020

In this PR

  • Moves source-of-truth HTML and CSS files into new src directory
  • Adds new dist directory
  • Adds build script in package.json to do the following:
    • Wipe any existing files in dist directory
    • Write file dist/dir-index.html that includes a minified, inlined version of external CSS files from src directory (and removes their corresponding <link>s to stylesheets)
  • Points code in test directory at the built dist/dir-index.html
  • Updates readme accordingly

Important!

Closes #6, BUT note that this will 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?)

(we kept the same filename, no changes to go-ipfs needed)

@jessicaschilling
Copy link
Contributor Author

@lidel and @ribasushi, could you please weigh in? If you're OK with this approach, we may want to consider using a release based on this in ipfs/kubo#7536, for efficiency. Thank you!

@ribasushi
Copy link
Contributor

@jessicaschilling I think this is great! One procedural nit: do we care how heavy the page is? If we do, perhaps we can use a real minifier in place of the basic tr -d \"\t\n\r\" ? One of these perhaps https://goalsmashers.github.io/css-minification-benchmark/

Note - if we do not care much about the pagesize and/or the source is already "pretty tight" - this comment should probably be disregarded.

A few stylistic nits remain, but if you decide to use a smarter minifier they are moot anyway.

@jessicaschilling
Copy link
Contributor Author

jessicaschilling commented Jul 25, 2020

@ribasushi Yep, the idea here was to keep the whole thing as lightweight as possible. We aren't using any other modules, so adding one just for this purpose didn't seem like the ideal way to go. If you've got ideas for selectively removing spaces in sed etc while preserving what's needed in css, that'd be great.

Copy link
Contributor

@ribasushi ribasushi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, I would add an extra newline for readability ( diff in comment )

package.json Outdated Show resolved Hide resolved
jessicaschilling and others added 2 commits July 27, 2020 10:55
Co-authored-by: Peter Rabbitson <ribasushi@protocol.ai>
@jessicaschilling
Copy link
Contributor Author

Thanks, @ribasushi -- over to you, @lidel, for any thoughts 😊

lidel added a commit to ipfs/kubo that referenced this pull request Jul 27, 2020
The file was moved to dist in:
ipfs/dir-index-html#40

License: MIT
Signed-off-by: Marcin Rataj <lidel@lidel.org>
lidel added a commit to ipfs/kubo that referenced this pull request Jul 27, 2020
The file was moved to dist/ in:
ipfs/dir-index-html#40

License: MIT
Signed-off-by: Marcin Rataj <lidel@lidel.org>
Copy link
Member

@lidel lidel left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I just realized dist/ is a breaking change because HTML file used by go-ipfs moved from dir-index-html/dir-index.html to dir-index-html/dist/dir-index.html, so when we switch go-ipfs to this, go-ipfs/assets/bindata.go and assets.go need to be changed.

To have a better understanding of the scope of changes I created ipfs/kubo#7561 – not terrible, but feels like unnecessary floating of the go-ipfs boat.

The main purpose of dir-index-html/dist/dir-index.html was to ensure output file won't be edited directly. I think we could keep old location dir-index-html/dir-index.html and add GithubAction that runs the build on PRs and if there are any uncommited changes - fail the build (I want to add it abyway – example)

Thoughts?

@jessicaschilling
Copy link
Contributor Author

@lidel Sounds like a good plan. Updated to remove dist directory and amend build script and test to look at the top-level dir instead. Back to you for the GitHub action finesse 😊 Thanks!

This adds GithubAction that  runs the build and checks for any unstaged
changes. This ensures `src/dir-index.html` match the output `dir-index.html`
in the main directory.
Copy link
Member

@lidel lidel left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM.

  • From the point of view of go-ipfs there are no functional changes (we output to the same file), but this repo is now much easier to maintain and contribute to.

  • To ensure sources and minified output do not diverge again I've added Github Action in 8a9c62e; should be enough to guard against committing state where output does not match sources:

    2020-07-27--22-30-47

  • Just to be sure there are no regressions I tested against @neatonk's PR and works as expected.

@jessicaschilling feel free to merge

@jessicaschilling jessicaschilling merged commit 9603194 into master Jul 27, 2020
@jessicaschilling jessicaschilling deleted the feat/add-build-script branch July 27, 2020 21:19
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Preprocessing: ensure dir-index and dir-index-uncat are in sync
3 participants