A plugin for persisting Alpine state across page loads
The compiled JS files (as a result of running npm run [build/watch]) to be included as a <script> tag for example are stored in each package’s packages/[package]/dist directory.
Each package should at least have: a “cdn” build that is self-initializing and can be included using the src attribute in a <script defer> tag, and a module.[esm/cjs].js file that is used for importing as a JS module (cjs for node, esm for everything else).
The bundling for Alpine V3 is handled exclusively by ESBuild. All of the configuration for these builds is stored in the scripts/build.js file.
Testing
There are 2 different testing tools used in this repo: Cypress (for integration tests), and Vitest (for unit tests).
All tests are stored inside the /tests folder under /tests/cypress and /tests/vitest.
If you wish to only run Cypress and open it’s user interface (recommended during development), you can run: npm run cypress
If you wish to only run Vitest tests, you can run npm run vitest like normal and target specific tests.
Alpine.js
Go to the Alpine docs for most things: Alpine Docs
You are welcome to submit updates to the docs by submitting a PR to this repo. Docs are located in the
/packages/docsdirectory.Stay here for contribution-related information.
Contribution Guide:
Quickstart
npm install&npm run build/packages/alpinejs/dist/cdn.jsfile from a<script>tag on a webpage and you’re good to go!Brief Tour
You can get everything installed with:
npm installin the root directory of this repo after cloning it locally.This repo is a “mono-repo” using npm workspaces for managing the packages. Each package has its own folder in the
/packagesdirectory.Rather than having to run separate builds for each package, all package bundles are handled with the same command:
npm run buildHere’s a brief look at each package in this repo:
The compiled JS files (as a result of running
npm run [build/watch]) to be included as a<script>tag for example are stored in each package’spackages/[package]/distdirectory.Each package should at least have: a “cdn” build that is self-initializing and can be included using the
srcattribute in a<script defer>tag, and amodule.[esm/cjs].jsfile that is used for importing as a JS module (cjs for node, esm for everything else).The bundling for Alpine V3 is handled exclusively by ESBuild. All of the configuration for these builds is stored in the
scripts/build.jsfile.Testing
There are 2 different testing tools used in this repo: Cypress (for integration tests), and Vitest (for unit tests).
All tests are stored inside the
/testsfolder under/tests/cypressand/tests/vitest.If you wish to only run Cypress and open it’s user interface (recommended during development), you can run:
npm run cypressIf you wish to only run Vitest tests, you can run
npm run vitestlike normal and target specific tests.