Tailwind 2.0 Escaping special characters problem
See original GitHub issueDescribe the problem:
I’ve updated tailwind from 1.9.6 to 2.0.1, and it crashes on the error:
ERROR in Module build failed (from ./node_modules/postcss-loader/dist/cjs.js):
Error: Unexpected '/'. Escaping special characters with \ may help.
It refers to this css fragment:
&__menu-item {
&_active::before {
@apply absolute top-1/2 left-1/2 w-full h-full box-content bg-brand-white transform -translate-x-6/12 -translate-y-6/12;
My key deps:
"@angular/core": "^10.2.0",
"postcss": "^8.1.2",
"postcss-import": "^13.0.0",
"postcss-loader": "^4.0.4",
"postcss-nested": "^5.0.1",
webpack.config.js
module.exports = {
module: {
rules: [
{
test: /\.css$/,
loader: 'postcss-loader',
options: {
postcssOptions: {
syntax: 'postcss',
plugins: ['postcss-import', 'tailwindcss', 'postcss-nested', 'autoprefixer'],
},
},
},
],
},
};
Btw, I use the latest LTS nodejs. Now I have to rollback to 1.9.6 to be able to continue the development.
Issue Analytics
- State:
- Created 3 years ago
- Comments:15 (3 by maintainers)
Top Results From Across the Web
Developers - Tailwind 2.0 Escaping special characters problem -
Describe the problem: I've updated tailwind from 1.9.6 to 2.0.1, and it crashes on the error: ERROR in Module build failed (from ....
Read more >Just-in-Time Mode - Tailwind CSS
Tailwind CSS v2.1 introduces a new just-in-time compiler for Tailwind CSS that generates your styles on-demand as you author your templates instead of ......
Read more >Error: PostCSS plugin tailwindcss requires PostCSS 8
As of v2.0, Tailwind CSS depends on PostCSS 8. ... To resolve this error, uninstall Tailwind and re-install using the compatibility build ...
Read more >How to install Tailwind CSS v2.0 using Ruby on Rails
Awesome video Andy. ... I was able to fix is by escaping special character '^', as bellow. yarn add tailwindcss@npm:@tailwindcss/postcss7-compat @ ...
Read more >tailwindcss | Yarn - Package Manager
... media="(prefers-color-scheme: light)" srcset="https://raw.githubusercontent.com/tailwindlabs/tailwindcss/HEAD/.github/logo-light.svg"> Tailwind CSS ...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Error is a little cryptic but your real problem is you were missing a
-1/5
value in your config:https://play.tailwindcss.com/wwZH8CHdeC?file=config
@adamwathan perhaps some more info might help point in the right direction, I’m also having this issue and it happens when trying to
@apply
a class with/
in it.I’m using the Tailwind Compositor plugin that generates classes with slashes for vertical rhythm control.
If I try to use to manually escape it
@apply text-8\/2 font-bold;
the error is: Thetext-8\/2
class does not exist, buttext-8/2
does. If you’re sure thattext-8\/2
exists, make sure that any@import
statements are being properly processed before Tailwind CSS sees your CSS, as@apply
can only be used for classes in the same CSS tree.If i set the class manually on the html element, it works.
The docs do point to how to escape them in a plugin, but not how to use them in css. So I’m not sure if this means the class needs to be escaped when generated by the plugin or when I try to use it in my own js or something else. If I find the time I’ll create a reproduction, but I thought it might be good to still add some info of my own until that.
Btw, thanks for your awesome work.