⏲ Time invest: 20 Minutes ––– 👩🎓 Level: Expert
Component libraries built with patternplate are all
about sharing your work and having a common place to
refer to - the much discussed Single Source of Truth.
To establish your component library as such you'll want to deploy it as a website.
We will …
patternplate build CLI command.gitOpen a terminal window and change into the directory holding your patternplate project.
Execute the following command to produce a static build of your component librarie's interface
yarn patternplate build --out='docs/patterns' --base='/patterns/'
patternplate creates a bunch of files in docs/patterns for you
tree docs/patterns/
docs/patterns/
├── api
│ ├── demo
│ │ ├── button.html
│ │ └── hello-world.html
│ ├── patternplate.web.components.js
│ ├── patternplate.web.cover-client.js
│ ├── patternplate.web.demo.js
│ ├── patternplate.web.mount.js
│ ├── patternplate.web.probe.js
│ └── state.json
├── doc
│ └── README
│ └── index.html
├── index.html
├── pattern
│ ├── button
│ │ └── index.html
│ └── hello-world
│ └── index.html
└── static
├── client.js
└── vendors.js
8 directories, 14 files
/docs and open /npx serve docs/ --open
Click on the patterns folder that shows up in your browser
You should see a fully functioning patternplate interface on the
patterns/ path 🎉. Let's bring this beauty online!
You may have noticed from our run of npx serve: patternplate build creates a document root suitable for deployment on any static webserver. This means there is nothing barring you from hosting it from your own systems.
Replace [username] with your GitHub username in all commands of this section.
Create a new repository on GitHub,
name it e.g. my-patternplate
Rerun our build to match its deployment target:
yarn patternplate build --out docs --base=/my-patternplate/
In your local repository, commit your changes
git add docs
git commit -m "docs: deploy static interface"
Set the remote of your local repository to your new remote repository on GitHub and push to it
git remote add origin git@github.com:[username]/my-patternplate.git
git push -u origin master
Open your repository settings at https://github.com/[username]/my-patternplate/settings and
scroll down to the GitHub Pages section.
Click on the dropdown under Source and select master branch docs folder. Make sure
to hit the save button next to the dropdown.
Navigate your browser to https://[username].github.com/my-patternplate/. You should see the very same interface you created locally earlier.
patternplate build creates a static build of your component library--base flag must match the url pathname the interface will be available atpatternplate build is well-suited for deployment to GitHub Pages,
but works for every static web sever