Skip to content

Conversation

rossjrw
Copy link
Collaborator

@rossjrw rossjrw commented Jan 24, 2021

This is a draft Pull Request for the restructuring changes we discussed. This PR is marked as a draft, so the little icon is grey instead of green, and you can't merge it. Once I've finished making my changes, I'll mark it as ready, the little icon will turn green, and you'll be able to merge it if you choose.

I edit and comment on my PRs frequently with notes to myself and stuff. If you have a question about what I'm doing, feel free to ask it here.

This PR must accomplish the following tasks, which I'll check off as I complete them:

  • Create .gitignore for the build process
  • Move source files from docs/ to src/
  • Implement a Gulp task runner to build CSS from source
  • Implement GitHub Actions to automatically rebuild compiled CSS
  • Make sure the minified CSS has the comment with attribution + licence
  • Scrape the repo's tags to build files for each version

For the Actions workflow, I'm thinking of having a latest endpoint that always has the latest version of the CSS, and then also an endpoint for each version (1.0.0, 1.3.0, 1.3.8, etc). The latest endpoint would be updated after every commit to the main branch; the version endpoints would only be updated every time a new release is created.

An NPM-based build process (https://www.npmjs.com) generates some files
that are really annoying if they're saved in the Git repository. Adding
these files to a .gitignore file forces Git to ignore them.

This commit adds the following to the .gitignore:

node_modules/ - Contains all the code for the dependencies installed by
NPM, and their dependencies, and their dependencies, and so on. Even if
the project only needs a few dependencies, this directory can quickly
become huge, and inflate the overall filesize of the repository. Because
everything here can quickly be reinstalled with a single command - npm
install - there's no reason to include in in version control.

package-lock.json - A file that locks the versions of this project's NPM
dependencies. It's supposed to be used for easily rolling back a
repository to see which version of which dependency introduced a bug,
and it's generally recommended that it should be committed. However,
I've never used it, and I generally find that it's more of a nuisance
than anything else.

dist/ - This is the directory that contains the output of the build
process: the compiled, minified CSS files. These files belong in the
gh-pages branch - they should never be committed to the main branch,
which is why the directory is marked as ignored.
docs/ was a GitHub-specific folder for distributing content via GitHub
Pages, that are intended for distribution of documentation. We'll be
converting the deployment process to an automatic build, so this naming
scheme is no longer required. This commit effectively switches to more
standard directory naming conventions by having the source files be in
the src/ dir.

Example of these conventions:
https://github.com/kriasoft/Folder-Structure-Conventions
There were some old minified CSS files in src/min/. There are not
supposed to be any minified source files - minification is for
distribution files - so these had to be removed. However, I'm not sure
which if any of them are still being used, and as myself and Grombald
discussed, it's not possible to dynamically generate them using Git
versioning because they were created before the codebase moved to Git.

Instead, I've moved them to a legacy/ dir, and I will configure the task
runner to move these files directly to the minified distribution dir
when the project is built.

New files should not be created in the legacy/ dir.
This commit adds Gulp, a task runner, to build the CSS.

If `npm run build` is run on the command line, Gulp will build the
project by passing all CSS through PostCSS and moving all the files to
dist/. The dist/ directory is in the .gitignore, so developers building
the project on their local machine will not commit it to the repository.

Later, I will set up a GitHub Actions workflow that builds the project
on every commit to the main branch. Instead of committing the dist/
directory to the main branch, it will be committed to the gh-pages
branch.

PostCSS is not currently configured to do anything.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant