Skip to content

Unclear how preserveHtmlElements works with Hugo #2348

Answered by adamwathan
jensamunch asked this question in Help
Discussion options

You must be logged in to vote

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:

// 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.

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@jensamunch
Comment options

Answer selected by adamwathan
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Help
Labels
None yet
2 participants
Converted from issue

This discussion was converted from issue #2348 on September 09, 2020 14:07.