import { defineConfig } from "vite";
import { resolve, join, parse } from "path";
import handlebars from "vite-plugin-handlebars";
import registerPartial from "handlebars";
export default defineConfig({
// project related config
plugins: [
[
handlebars({
partialDirectory: resolve(__dirname, "src/partials"),
reloadOnPartialChange: true,
reload: true,
}),
],
],
});
export default function HandlebarUpdate() {
return {
name: "HandlebarUpdate",
enforce: "post",
handleHotUpdate({ file, server }) {
if (file.endsWith(".hbs")) {
console.log("reloading handlebar file...");
server.ws.send({
type: "full-reload",
path: "*",
});
}
},
};
}
import HandlebarUpdate from "./src/js/files/handlebarUpdate";
HandlebarUpdate(),