Only run PurgeCSS in production builds

This commit is contained in:
Niek van der Maas
2023-03-03 16:56:19 +01:00
parent baac66327e
commit 5a0d6b7561

View File

@@ -4,15 +4,24 @@ import { svelte } from "@sveltejs/vite-plugin-svelte";
import purgecss from "@fullhuman/postcss-purgecss";
// https://vitejs.dev/config/
export default defineConfig({
plugins: [svelte()],
css: {
postcss: {
plugins: [
purgecss({
content: ["./**/*.html", "./**/*.svelte"],
}),
],
},
},
export default defineConfig(({ command, mode, ssrBuild }) => {
// Only run PurgeCSS in production builds
if (command === "build") {
return {
plugins: [svelte()],
css: {
postcss: {
plugins: [
purgecss({
content: ["./**/*.html", "./**/*.svelte"],
}),
],
},
},
};
} else {
return {
plugins: [svelte()],
};
}
});