A simple boilerplate to publish standard Stimulus Controller as an NPM package
- Rollup: Roll up configuration to build umd, es, cjs bundles.
- Predefined scripts: yarn build, yarn dev, yarn test... commonly used predefined scripts.
- Testing environment: Mocha, Chai, Karma & the gang to easily test your controller.
To create a new package clone and rename this repo
git clone https://github.com/adrienpoly/stimulus-library-boilerplate.git my-controller-name
cd my-controller-name
rm -rf .git
yarn install
- rename the package name in
package.json
- code your controller in
src/index.js
- add tests & fixtures in
spec
yarn build
& publish it withnpm publish
(you need to create an account on npm first)
yarn build
: bundle in production mode & builds the package in thedist
directoryyarn dev
: watch for changes & bundle in development modeyarn test
: launch the test suite in a headless browseryarn test:watch
: watch for changes & launch the test suite in a headless browseryarn test:browser
: watch for changes & launch the test suite in a chrome browser
When developing a controller you might want to set up a little playground environment to play & test your controller.
In ./playground
you can modify index.html
& index.js
to suit your need.
The playground can be started with :
yarn start
Bug reports and pull requests are welcome.
This package is available as open source under the terms of the MIT License.