summaryrefslogtreecommitdiff
path: root/packages/integrations/alpinejs/src/index.ts
blob: 4a296b8c1f5072ccee38dc3b2de8ed4142738645 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
import type { AstroIntegration } from 'astro';

export default function createPlugin(): AstroIntegration {
	return {
		name: '@astrojs/alpinejs',
		hooks: {
			'astro:config:setup': ({ injectScript }) => {
				// This gets injected into the user's page, so the import will pull
				// from the project's version of Alpine.js in their package.json.
				injectScript(
					'page',
					`import Alpine from 'alpinejs'; window.Alpine = Alpine; Alpine.start();`
				);
			},
		},
	};
}