Closed pavelloz closed 4 years ago
Please attach your webpack config :)
Ouh! I just realized, i dont have tailwind.config.js - which might be unusual (i dont see a need ATM). This might be it?
@import
statements must come first in a CSS file according to the spec and that is why you have to use @import 'tailwindcss/base
.
This is explained here:
https://tailwindcss.com/docs/installation#2-add-tailwind-to-your-css
This behavior comes from the postcss-import
plugin and is by design, and is not a bug in our code:
https://github.com/postcss/postcss-import
This plugin attempts to follow the CSS @import spec; @import statements must precede all other statements (besides @charset).
Here's another related discussion:
@adamwathan I'm having the same issue, still.
/* purgecss start ignore */
@tailwind base;
@tailwind components;
/* Override react-toastify CSS styles https://fkhadra.github.io/react-toastify/how-to-style */
.Toastify__toast-container {
width: 450px !important;
}
.Toastify__toast {
font-family: inherit !important;
min-height: 0px !important;
padding: 0px !important;
border-radius: 0px !important;
}
.Toastify__toast-body {
width: 100% !important;
height: 100% !important;
padding: 0px !important;
margin: 0px !important;
}
/* purgecss end ignore */
@tailwind utilities;
Yet the .Toastify
classes are not making it to tailwind.output.css
.
My Tailwind config has purge.enabled: false
because I'm using postcss.config.js
:
const trimEnd = require('lodash.trimend');
const purgeContent = ['./public/**/*.html', './src/**/*.tsx', './src/**/*.jsx', './src/**/*.js'];
// https://tailwindcss.com/docs/controlling-file-size#setting-up-purge-css-manually
// https://github.com/tailwindlabs/tailwindcss/blob/master/src/lib/purgeUnusedStyles.js
const purgeExtractor = (content) => {
// Capture as liberally as possible, including things like `h-(screen-1.5)`
const broadMatches = content.match(/[^<>"'`\s]*[^<>"'`\s:]/g) || [];
const broadMatchesWithoutTrailingSlash = broadMatches.map((match) => trimEnd(match, '\\'));
// Capture classes within other delimiters like .block(class="w-1/2") in Pug
const innerMatches = content.match(/[^<>"'`\s.(){}[\]#=%]*[^<>"'`\s.(){}[\]#=%:]/g) || [];
return broadMatches.concat(broadMatchesWithoutTrailingSlash).concat(innerMatches);
};
const production = process.env.NODE_ENV === 'production';
module.exports = {
plugins: [
require('tailwindcss')('./tailwind.config.js'),
production ? require('autoprefixer') : null,
production ? require('cssnano')({ preset: 'default' }) : null,
production
? require('@fullhuman/postcss-purgecss')({
content: purgeContent,
defaultExtractor: purgeExtractor,
})
: null,
],
};
I have app.css which looks like this:
Webpack spits out:
When i comment tailwind, so the code becomes this:
It spits out much, much more.
I thought ignore means purgecss will ignore everything inside, so there should be no difference, or at least when i comment something out in there, it will become smaller, not 5x bigger and with completely different content.
It looks like no matter what i do in this ignore block, its either tailwind, or the rest.
I found a workaround (which leads me to believe that it is only tailwind issue). I changed how i import tailwind:
And now it works fine.