Skip to content
This repository was archived by the owner on Feb 3, 2020. It is now read-only.

Gatsby, Tailwind, PurgeCSS: <body> tag refuses any styling #40

@2x2xplz

Description

@2x2xplz

Before you open an issue, please check if a similar issue already exists or has been closed before.

Describe the bug
Building a site with Gatsby. Using PurgeCSS as a PostCSS plugin after Tailwind. When PurgeCSS is active, the body tag is stripped of all styling, and the user-agent (browser) defaults to an 8px margin on all sides.

This despite having

body {
  @apply m-0 bg-gray-300  /* tailwind syntax */
}

in my global.css file. As soon as I remove PurgeCSS from the build, everything works fine, the body margins go to zero and the background is grey.

To Reproduce

  1. Add PurgeCSS to a working site:
module.exports = {
  plugins: [
    require('tailwindcss'),
    require('postcss-nesting'),
    require('autoprefixer'),    
    ...process.env.NODE_ENV === 'production' ? [purgecss] : []
  ],
}
  1. gatsby build
  2. gatsby serve
  3. open browser, see lack of body styling. other styles are fine!

Expected behavior
Everything else related to PurgeCSS works great. It stripped 600kb out of my bundle. But it appears the body tag is immune or incompatible or something.

Desktop (please complete the following information):

  • OS: Windows 10
  • postcss-purgecss v. 1.3.0
  • Gatsby version 2.15.20, Gatsby CLI version 2.7.49

Additional context

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions