Open james-nash opened 5 years ago
In a personal project I have managed to pull this off using the approach outlined in Fractal's docs, i.e. exporting copies of the template files somewhere into the dist/
dir and then shipping those in an NPM package.
It's relatively straightforward for consuming projects to then configure their Nunjucks environment to look for templates in that directory (and our build-api
can assist with this) in addition to whatever local template directory(-ies) they have.
However, I think we need to be picky about which templates we export. There's little value in all the ones that are "just" plain HTML elements. Likewise templates and pages probably shouldn't be published either.
I reckon (non-element) atoms, molecules and organisms are the sweet spot.
Unfortunately our current organisation is a mess. Also, in a misguided attempt to get lineage links for ALL THE THINGS, I regretfully overengineered and entangled our Nunjucks templates.
As a way forward, I therefore propose:
Then we can update our build to copy out the templates we want to ship and publish them to NPM, which will be covered by this issue.
Is your feature request related to a problem? Please describe. We maintain a set of HTML templates (written in Nunjucks) for our pattern library. Those same templates could be useful for downstream consumers such as the Buildit website, so we should publish them as an
@buildit/gravity-ui-nunjucks
NPM package.A while ago we decided to work towards that by:
This issue is to cover the last and final step.
Describe the solution you'd like First off, it's best to wait for the migration to Fractal (#264) to complete, since that affects the structure of the templates.
Once that's in place, we'll need to figure out how to make the templates usable without Fractal (which has it's own
@..
shorthand naming scheme for importing/including other templates). Possible options are:@...
shorthand.With a solution to the above in place, we should then get
semantic-release
enabled and configured properly for the@buildit/gravity-ui-nunjucks
package and get it published.