Unclear how preserveHtmlElements works with Hugo #2348
Answered
by
adamwathan
jensamunch
asked this question in
Help
-
Hugo calls purgecss manually (see below) and preserveHtml doesn't seem to be respected What's the recommended way to do this?
|
Beta Was this translation helpful? Give feedback.
Answered by
adamwathan
Sep 9, 2020
Replies: 1 comment 1 reply
-
If Hugo is using PurgeCSS directly and not the Purge functionality built in to Tailwind, then Tailwind's purge options will have no effect since Hugo is completely bypassing them. Personally I would use the built-in Purge and enable it manually based on the I would expect this configuration to do what you want: // postcss.config.js
const autoprefixer = require("autoprefixer")({});
module.exports = {
plugins: [
require("postcss-import"),
require("tailwindcss")("assets/css/tailwind.config.js"),
...(process.env.HUGO_ENVIRONMENT === "production" ? [autoprefixer] : []),
],
};
// tailwind.config.js
module.exports = {
purge: {
enabled: process.env.HUGO_ENVIRONMENT === "production",
content: ["layouts/**/*.html"],
options: {
whitelist: ["bg-paceA", "bg-paceB", "bg-paceC", "bg-paceD"],
},
},
// ...
}; |
Beta Was this translation helpful? Give feedback.
1 reply
Answer selected by
adamwathan
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
If Hugo is using PurgeCSS directly and not the Purge functionality built in to Tailwind, then Tailwind's purge options will have no effect since Hugo is completely bypassing them.
Personally I would use the built-in Purge and enable it manually based on the
HUGO_ENVIRONMENT
variable.I would expect this configuration to do what you want: