alexlafroscia / vite-plugin-handlebars

Vite support for Handlebars
170 stars 22 forks source link

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

Open jjaimealeman opened 2 years ago

jjaimealeman commented 2 years ago

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

Any solutions ?

jonatanklosko commented 2 years ago

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 commented 2 weeks ago

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({ ... }),
  ],