Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

build(improvements) #602

Merged
merged 8 commits into from
Jul 5, 2024
Merged

build(improvements) #602

merged 8 commits into from
Jul 5, 2024

Conversation

chrispymm
Copy link
Contributor

This PR updates the build pipeline to improve a few things:

  • Tweak husky config
  • Drop webpack as a requirement
  • Improvements for reloading in dev

Husky

The change to the husky config prevents double-prompting which occurs when git commit is aliased to git cz.

Drop Webpack

Previously there were 3 build tools 11ty, gulp, and webpack. With gulp handling the build & dist bundle of the package, 11ty handling the docs templates and webpack handling the docs site assets.

Webpack was mostly being used solely for copying files - which seems slightly overkill. Also using 3 tools was slow, and due to the parallel nature of the task would often result in multiple reloads. So this PR moves the tasks done by webpack to 11ty and gulp.

Dev reloading

Previously, changes to the src/component files would not be watched and picked up in the dev site, making local dev a bit slow.

This PR adds the ability to pass an ENV='dev' environment variable to 11ty, which modifies the nunjucks environment to look in the src/ directory for nunjucks templates. Allowing for 11ty to rebuild when a change is made to them.

The changes in this PR mean that now 11ty is responsible for watching and building the docs site assets, and gulp now has the build:docs task to copy the assets required for the site, and the watch:package task to watch for changes in the component scss and js files.

In order to achieve this, the assets directory has been moved within the docs directory, to place it within 11ty's watch scope.

Gulp does not copy across the all.js file from src, 11ty is configured to watch the all.js file. When gulp builds the package files, generating all.js this triggers an 11ty rebuild.

This means that now, any change to any .njk, .md, .js or .scss file will trigger a fast rebuild and reload of the site in dev.

chrispymm added 3 commits July 4, 2024 13:42
…in development

By default the nunjucks environment loads components from the ./package directory.  This means
changes to a component won't be loaded in development.  This PR updates the nunjucks environment to
load from the ./src directoy when the ENV var is det to dev
When aliasing git commit to git cz alongside the pre-commit-hook would cause the interactive prompt
to run twice.  This Pr updates the pre-commit-hook to only run if a commit message has not already
been provided
… src directory

Documentation examples by default load components from the built /package directory.  This PR adds
the ability to pass an ENV='dev' flag to the eleventy command to enable loading of components direct
from the /src directory. This also adds a gulp watcher to rebuild the package css and js files
during development.

This needs further work! We have three file watchers running in parallel to build/rebuild the
docs site in development. (11ty, webpack, and gulp) It would be good if we could use just one!
@chrispymm chrispymm requested a review from a team as a code owner July 4, 2024 14:21
We were using 3 build tools in combination: 11ty, webpack, and gulp.  This was overly complex, a bit
unnecessary, and was slow.  Webpack was only really being used to copy files - which can very easily
eb done by gulp. This PR removes the webpack dependency and pipeline in favour of gulp. the pipeline
is now setup such that any changes in dev for a component will trigger a rebuild of the assets and
the 11ty docs making working on a component much faster as changes to both nunjucks templates and
js/scss files trigger a reload in the browser.
@chrispymm chrispymm force-pushed the update-build-pipeline branch from 7be620b to 50998c6 Compare July 4, 2024 14:29
@chrispymm chrispymm force-pushed the update-build-pipeline branch from 3b96d0a to 1e4c6ec Compare July 4, 2024 14:47
.eleventy.js Outdated Show resolved Hide resolved
.eleventy.js Outdated Show resolved Hide resolved
.eleventy.js Show resolved Hide resolved
@chrispymm chrispymm force-pushed the update-build-pipeline branch from e379edf to 50bcc69 Compare July 5, 2024 14:11
@chrispymm chrispymm force-pushed the update-build-pipeline branch from 50bcc69 to 2dd36cf Compare July 5, 2024 16:00
@chrispymm chrispymm merged commit 07ab9af into main Jul 5, 2024
9 checks passed
@chrispymm chrispymm deleted the update-build-pipeline branch July 5, 2024 16:06
@gregtyler
Copy link
Contributor

🎉 This PR is included in version 2.2.0 🎉

The release is available on:

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants