0
Fork 0
mirror of https://github.com/withastro/astro.git synced 2025-01-06 22:10:10 -05:00
astro/.changeset/heavy-beers-tickle.md
Florian Lefebvre 1153331cbb
feat(alpinejs): allow customizing the Alpine instance (#9751)
* feat(alpinejs): allows customzing the Alpine instance

* chore: add e2e tests

* fix: rename script

* Update index.ts

* fix: lockfile
2024-01-24 14:43:03 +00:00

31 lines
No EOL
850 B
Markdown

---
"@astrojs/alpinejs": minor
---
Allows extending Alpine using the new `entrypoint` configuration
You can extend Alpine by setting the `entrypoint` option to a root-relative import specifier (for example, `entrypoint: "/src/entrypoint"`).
The default export of this file should be a function that accepts an Alpine instance prior to starting, allowing the use of custom directives, plugins and other customizations for advanced use cases.
```js
// astro.config.mjs
import { defineConfig } from 'astro/config';
import alpine from '@astrojs/alpinejs';
export default defineConfig({
// ...
integrations: [alpine({ entrypoint: '/src/entrypoint' })],
});
```
```js
// src/entrypoint.ts
import type { Alpine } from 'alpinejs'
export default (Alpine: Alpine) => {
Alpine.directive('foo', el => {
el.textContent = 'bar';
})
}
```