vite-plugin-handlebars icon indicating copy to clipboard operation
vite-plugin-handlebars copied to clipboard

Using with TailwindCSS - partials do not refresh when editting tailwind classes

Open jjaimealeman opened this issue 2 years ago • 2 comments

reloadOnPartialChange: true, added to vite.config.js but it makes no difference.

Any solutions ?

jjaimealeman avatar May 11 '22 20:05 jjaimealeman

I think the problem lies here:

https://github.com/alexlafroscia/vite-plugin-handlebars/blob/281c36a9b90435676b62a26d83b6a5eff3c811bf/src/index.ts#L47-L55

Specifically, returning [] skips any further processing, meaning that postcss (hence tailwind) isn't triggered at all.

I'm not sure how handleHotUpdate should look exactly, but a workaround is to remove it entirely:

// TODO: remove once https://github.com/alexlafroscia/vite-plugin-handlebars/issues/192 is resolved
function handlebarsOverride(options) {
  const plugin = handlebars(options);
  // Currently handleHotUpdate skips further processing, which bypasses
  // postcss and in turn tailwind doesn't pick up file changes
  delete plugin.handleHotUpdate;
  return plugin;
}
  plugins: [
    handlebarsOverride({ ... }),
  ],

jonatanklosko avatar Jun 30 '22 11:06 jonatanklosko

didn't help when simple HTML partial changes

I think the problem lies here:

https://github.com/alexlafroscia/vite-plugin-handlebars/blob/281c36a9b90435676b62a26d83b6a5eff3c811bf/src/index.ts#L47-L55

Specifically, returning [] skips any further processing, meaning that postcss (hence tailwind) isn't triggered at all.

I'm not sure how handleHotUpdate should look exactly, but a workaround is to remove it entirely:

// TODO: remove once https://github.com/alexlafroscia/vite-plugin-handlebars/issues/192 is resolved
function handlebarsOverride(options) {
  const plugin = handlebars(options);
  // Currently handleHotUpdate skips further processing, which bypasses
  // postcss and in turn tailwind doesn't pick up file changes
  delete plugin.handleHotUpdate;
  return plugin;
}
  plugins: [
    handlebarsOverride({ ... }),
  ],

sKopheK avatar Jul 03 '24 10:07 sKopheK