From 90a7d39c3d4f99f4e601168742f896cc1aa08499 Mon Sep 17 00:00:00 2001 From: Sven Schwyn Date: Mon, 5 Jan 2026 21:15:39 +0100 Subject: [PATCH] Add an example for how to use assets via Node.js --- content/v2.3/assets/overview.md | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/content/v2.3/assets/overview.md b/content/v2.3/assets/overview.md index e66eb5f7..ecee5878 100644 --- a/content/v2.3/assets/overview.md +++ b/content/v2.3/assets/overview.md @@ -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.