Skip to content

Using extensions with Vite #1469

@matteocontrini

Description

@matteocontrini

Hello, I'm using Vite as a bundler and I'm unable to make htmx extensions work.

If I write:

import 'htmx.org';
import 'htmx.org/dist/ext/preload.js';

it compiles correctly but I then get this error in the console:

Uncaught ReferenceError: htmx is not defined

I've also tried making sure that htmx is available globally:

import * as htmx from 'htmx.org';
window.htmx = htmx;

But it doesn't seem to make a difference.

So is there a way to use extensions with a bundler like Vite?

Thanks.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions