All threads / How add PurgeCss with TailwindCss?

Ask A Question

Notifications

You’re not receiving notifications from this thread.

How add PurgeCss with TailwindCss?

Nikola Okonesh asked in CSS

https://next.tailwindcss.com/docs/controlling-file-size

postcss.config.js

const purgecss = require('@fullhuman/postcss-purgecss')({
  content: [
    './**/**/**/*.erb',
    './**/**/**/**/*.erb',
  ],
  extractors: [
    {
      extractor: class {
        static extract(content) {
          return content.match(/[A-Za-z0-9-_:/]+/g) || [];
        }
      },
      extensions: ['html']
    }
  ]
})

module.exports = {
  plugins: [
    require('tailwindcss'),
    require('autoprefixer'),
    require('postcss-import'),
    require('postcss-flexbugs-fixes'),
    require('postcss-preset-env')({
      autoprefixer: {
        flexbox: 'no-2009'
      },
      stage: 3
    }),
  ]
}

How to do right? Thanks

Hey Nikola,

I just posted an episode on this yesterday: https://gorails.com/episodes/purgecss

Join the discussion

Want to stay up-to-date with Ruby on Rails?

Join 37,629+ developers who get early access to new tutorials, screencasts, articles, and more.

    We care about the protection of your data. Read our Privacy Policy.

    logo Created with Sketch.

    Ruby on Rails tutorials, guides, and screencasts for web developers learning Ruby, Rails, Javascript, Turbolinks, Stimulus.js, Vue.js, and more. Icons by Icons8

    © 2020 GoRails, LLC. All rights reserved.