Skip to content

Commit

Permalink
vite: ensure woff2 files are not cached on dev
Browse files Browse the repository at this point in the history
  • Loading branch information
fehmer committed Jun 3, 2024
1 parent bf7bb37 commit b8cba96
Showing 1 changed file with 22 additions and 1 deletion.
23 changes: 22 additions & 1 deletion frontend/vite.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -185,6 +185,27 @@ const BASE_CONFIG = {
},
};

/** @type {import("vite").UserConfig} */
const DEV_CONFIG = {
plugins: [
{
name: "force-disable-cache",
configureServer(server) {
server.middlewares.use((req, res, next) => {
if (req.url.endsWith("woff2")) {
res.setHeader(
"Cache-Control",
"no-cache, no-store, must-revalidate"
);
res.setHeader("Pragma", "no-cache");
}
next();
});
},
},
],
};

/** @type {import("vite").UserConfig} */
const BUILD_CONFIG = {
plugins: [
Expand Down Expand Up @@ -259,7 +280,7 @@ export default defineConfig(({ command }) => {
}
return mergeConfig(BASE_CONFIG, BUILD_CONFIG);
} else {
return BASE_CONFIG;
return mergeConfig(BASE_CONFIG, DEV_CONFIG);
}
});

Expand Down

0 comments on commit b8cba96

Please sign in to comment.