How to import Alpine in custom script
I would like to extract an Alpine.data() component to a separate js file located in
resources/js/filament/app.js
.
The problem is the import Alpine from 'alpinejs'
I get a browser error. Presumably because it's not being compiled and just copied across to the public folder.
Am I missing something here...?Solution:Jump to solution
use
```js
document.addEventListener('alpine:init', () => {
//your code..
})...
6 Replies
maybe php artisan filament:assets?
Already using that command. Unfortunately, just copies it to the public folder.
I think you don't need to import alpine again.. what are you doing in the app.js?
Register a reusable Alpine data obj
Solution
use
Well the error is gone... so I think this was it thanks😄 Will accept it once I test it
Cheers, all working.