-
-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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
Using extensions with Vite #1469
Comments
At the moment all extensions are missing a UMD wrapper. Therefore, you need to use the @rollup/plugin-inject // vite.config.js
import inject from '@rollup/plugin-inject'
import { defineConfig } from 'vite'
export default defineConfig({
plugins: [
inject({
htmx: 'htmx.org'
}),
],
}) After configuring the plugin in your import 'htmx.org/dist/ext/preload.js'; |
@xhaggi that's helpful, thank you! However I think there's still something else missing. For example, the It appears that the Any ideas? I think I can provide a sample project if it's helpful. |
Not really and yes, please provide some code or a sample project. |
I pushed a sample project here: https://github.com/matteocontrini/vite-htmx-problem I might be doing something wrong but if you run it you'll see that preload doesn't work and in the console there is no If you instead open Thanks! |
Thank you. I looked deeper into this issue and the reason why it does not work, is the fact that htmx initialize itself on DOM ready. A |
I imagined it was something like that but I'm not very familiar with htmx internals. Thanks a lot for investigating and working on this! |
Is this issue still open and is there an example of using Vite with htmx? |
@Sciumo I have the same problem, as a workaround I use htmx scripts at the end of the body, and it works fine. But I agree it would be great to have it working with Vite. Hope it helps. |
The loading issue with extensions is fixed in the next version.
This is not fixed and you need to use such a workaround. I have created a separate issue for this bigskysoftware/htmx-extensions#128. |
Closing for this reason. |
Just fyi, for anyone trying to use HTMX with Astro, it isn't possible to use |
Hello, I'm using Vite as a bundler and I'm unable to make htmx extensions work.
If I write:
it compiles correctly but I then get this error in the console:
I've also tried making sure that htmx is available globally:
But it doesn't seem to make a difference.
So is there a way to use extensions with a bundler like Vite?
Thanks.
The text was updated successfully, but these errors were encountered: