Writing a Snowpack Community Plugin
Snowpack is a tool for building web applications with less tooling and 10x faster iteration. Snowpack comes with a starter generator called Create Snowpack App, it has official plugins for most of the frameworks.
But what if we wanted to build a custom community plugin?
Create Snowpack App (CSA)
You can use create-snowpack-app with:
You are excused if this feels familiar to a popular react tool.
Community Starter
A community starter is a repository that you get to maintain using Snowpack and published to NPM (or any of the other hosted services). You can initialise a new project using your template and CSA.
If your template is called my-custom-template and hosted to NPM, you would be able to use it with:
First, we will start with a basic template:
Now CSA will intialise a repository named my-custom-template that contains the snowpack template @snowpack/app-template-blank. Now you can proceed to make changes you want in the template.
I'm just choosing to start with blank, you can choose to start with any other template
Add required fields
- It needs a name
Give it a name in package.json, this is also your template name.
Note that this name needs to be unique in the NPM package registry. You can also scope it to something like @npmuser@my-custom-template, these are known as scoped packages.
- It needs a version
Give it a version.
- Add the keyword.
CSA requires the template to have a specific keyword: csa-template.
Publishing package to NPM
There are several articles and videos if you are not familar with publishing or haven't done this before. But the basic idea is:
You can also use one of the several tools that help with this process. One of my absolute favorites is np.
Using the template
You can now use the template as mentioned with:
Have fun 🎉