Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add an example for how to use assets via Node.js #271

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions content/v2.2/assets/overview.md
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,23 @@ public/assets

Since `public/assets/login/app.js` is a bundle, it includes the content from the `app/assets/js/login/resetPassword.js` file it imported.

## Assets from Node.js

To use a Node.js package such as Alpine.js, add it as a production dependency:

```bash
npm install alpinejs
```

To bundle it, add the following to the entry point of your choice:

```js
import Alpine from "alpinejs";

window.Alpine = Alpine;
Alpine.start();
```

## Asset bundles

The process of generating an asset bundle involves grouping multiple files (typically JavaScript or CSS) referenced from your entry point into single bundled file. This consolidation is helpful for web app performance, since it reduces the number of HTTP requests required to load a single page.
Expand Down