Skip to content
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

htmlTemplate is not a function #37

Open
RaminderRandhawa91 opened this issue Jan 22, 2024 · 4 comments
Open

htmlTemplate is not a function #37

RaminderRandhawa91 opened this issue Jan 22, 2024 · 4 comments

Comments

@RaminderRandhawa91
Copy link

Getting this error after updating to Vite 5 and after adding type=""module" in package.json as required in Vite 5 . Is there workaround this ?

@randhawa-bauercontrols
Copy link

Please help me out

@dinacel
Copy link

dinacel commented Feb 9, 2024

Rewrite your "vite.config.js":

import htmlTemplate from 'vite-plugin-html-template';
...
export default defineConfig({
  plugins: [
    // ...other plugins
    htmlTemplate.default(/* options */)
  ]
});

The module exports the function in "default" property.

@tatsmaki
Copy link

Up because it is not correct with TypeScript

@hughns
Copy link

hughns commented Dec 18, 2024

Up because it is not correct with TypeScript

I concur that this is broken when using in TypeScript projects.

A possible workaround:

import htmlTemplate from "vite-plugin-html-template";

export default defineConfig({
  plugins: [
	(htmlTemplate as unknown as { default: typeof htmlTemplate }).default(/* options */)
  ]
});

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants