Accudio / async-alpine

Async Alpine brings advanced code splitting and lazy-loading to Alpine.js components!
https://async-alpine.dev
Apache License 2.0
152 stars 12 forks source link

Enable multiple matches in AsyncAlpine.alias() #32

Closed scruffymongrel closed 9 months ago

scruffymongrel commented 11 months ago

I have components organised as follows:

components/
  Button/
    Button.island.js
    Button.jsx

In my Vite entry file, I'm using AsyncAlpine.alias('components/[name]/[name].island.js').

As only the first instance of [name] is replaced, I get a 404 on http://localhost:5173/components/Button/[name].island.js.

If I remove the second instance of [name] and rename Button.island.js to island.js, everything works as expected.

Would you be happy to enable replacement of multiple instances of [name] in AsyncAlpine.alias()?

Accudio commented 11 months ago

Yep absolutely, I'd definitely be happy to do that. That's something I missed due to using .replace instead of .replaceAll.

I can update next week, or you're welcome to make a PR with that change.

scruffymongrel commented 11 months ago

Excellent. Have created a PR (#34). Thanks :)