-
Notifications
You must be signed in to change notification settings - Fork 4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Error: Expected an opening square bracket (using postcss-purgecss and postcss-preset-env) #1190
Comments
Hey thanks for the excellently constructed issue! I looked into this and the source of the problem appears to be a bug in the It is duplicating your focus-within selectors and replacing the pseudo-class ( .focus-within\:bg-transparent[focus-within] {
background-color: transparent;
}
.focus-within\:bg-transparent:focus-within {
background-color: transparent;
} The problem is it's also replacing the .md\[focus-within]\:bg-transparent[focus-within] {
background-color: transparent;
}
.md\:focus-within\:bg-transparent:focus-within {
background-color: transparent;
} This is because the plugin is naively doing a search and replace on https://github.com/jonathantneal/postcss-focus-within/blob/master/index.js#L3 The fix will be similar to what was done on the csstools/postcss-selector-not#11 I'll open an issue on that plugin but in the mean time if you aren't actually using the polyfill you can just disable that plugin in const purgecss = require("@fullhuman/postcss-purgecss")({
// paths to all of the template files in the project
content: ["./src/**/*.html", "./src/**/*.tsx", "./public/**/*.html"],
// default extractor including tailwind's special characters
defaultExtractor: content => content.match(/[A-Za-z0-9-_:/]+/g) || []
});
module.exports = {
plugins: [
require("tailwindcss"),
require("postcss-preset-env")({
stage: 1,
features: {
'focus-within-pseudo-class': false
}
}),
...(process.env.NODE_ENV === "production" ? [purgecss] : [])
]
}; |
Opened issue on the plugin repo, will try to fix myself soon if I can: csstools/postcss-focus-within#3 Closing here since it's not something we can fix from inside Tailwind but thanks for helping us discover this and track it down. |
Awesome, thank you for the fast reply! And thank you for your work on Tailwind :) |
I have the same exact issue on a Statamic v3 project (which uses Laravel Mix). Is there a way to apply this fix with Mix? Error: Expected an opening square bracket. |
i had similar issue i solved adding purge: ['./components//*.{js,ts,jsx,tsx}', './pages//*.{js,ts,jsx,tsx}'], to my tailwind.config.js after that i was able to build my app |
It seems that tailwindcss classes is removed. I solved by using:
|
It's working with @hieu-nv 's solution, but what is it actually doing ? |
None of the solutions mentioned above worked for me. Here's the code in postcss.config.js that fix it using Next.js 10 and React 17:
|
FIX for Error: Expected an opening square bracket (using postcss-purgecss and postcss-preset-env) tailwindlabs/tailwindcss#1190 (comment)
For Laravel Mix you can disable the const postCssPlugins = [
/**
* 🎨 Styles: Tailwind CSS
*/
require('tailwindcss')('./tailwind.config.js'),
/**
* 🎨 Styles: Polyfills
* Postcss preset env lets you use pre-implemented css features
* See https://cssdb.org/ for supported features
* https://github.com/csstools/postcss-preset-env#readme
*/
require("postcss-preset-env")({
stage: 1,
features: {
'focus-within-pseudo-class': false
}
}),
];
mix.options({ postCss: postCssPlugins }); |
🤦 This also happens if you have two |
Thanks so much, just saved my day with this solution. |
I've encountered this error when trying to build styles for production. I have a create-react-app with tailwindcss and postcss. I'm not sure where the problem lies exactly but I've boiled it down to this config to recreate it:
package.json
:postcss.config.js
tailwind.config.js
I get this error when building the styles for a production environment (so with purgecss enabled):
yarn build:css --env=production
So, I've checked the generated css, and some of it appears to be broken:
I've created a repo with the minimal config displaying the error: https://github.com/yassinedoghri/tailwind-build-error
The text was updated successfully, but these errors were encountered: