Skip to content

Commit

Permalink
update CSP build/installation docs (#3762)
Browse files Browse the repository at this point in the history
there has been a lot of confusion on how to use the CSP build, so this commit hopefully clears them up, and provides more explicit instructions on how to "build from source".

some of the wording and code examples make it seem like an NPM package is available, so we'll update that to avoid confusion.

Co-authored-by: Caleb Porzio <[email protected]>
  • Loading branch information
browner12 and calebporzio authored Oct 18, 2023
1 parent 1e72dfb commit b124ed7
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions packages/docs/src/en/advanced/csp.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,22 +14,29 @@ In order to accommodate environments where this CSP is necessary, Alpine will of
<a name="installation"></a>
## Installation

The CSP build hasn't been officially released yet. In the meantime, you may [build it from source](https://github.com/alpinejs/alpine/tree/main/packages/csp). Once released, like all Alpine extensions, you will be able to include this either via `<script>` tag or module import:
The CSP build hasn’t been officially released yet. In the meantime, you may build it from source. To do this, clone the [`alpinejs/alpine`](https://github.com/alpinejs/alpine) repository and run:

```shell
npm install
npm run build
```

This will generate a `/packages/csp/dist/` directory with the built files. After copying the appropriate file into your project, you can include it either via `<script>` tag or module import:

<a name="script-tag"></a>
### Script tag

```alpine
<html>
<script src="alpinejs/alpinejs-csp/cdn.js" defer></script>
<script src="/path/to/cdn.js" defer></script>
</html>
```

<a name="module-import"></a>
### Module import

```js
import Alpine from '@alpinejs/csp'
import Alpine from './path/to/module.esm.js'

window.Alpine = Alpine
window.Alpine.start()
Expand Down

0 comments on commit b124ed7

Please sign in to comment.