Skip to content
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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

Tailwind + Parcel: @parcel/transformer-css: Unsupported pseudo class or element: global #9418

Closed
benlau opened this issue Dec 5, 2023 · 1 comment

Comments

@benlau
Copy link

benlau commented Dec 5, 2023

馃悰 bug report

Using parcel (2.10.3) and tailwindcss(3.3.6) together may result in the following error: @parcel/transformer-css: Unsupported pseudo-class or element: global if the :global operator is found in the module CSS. In such cases, it cannot be used.

Disabling Tailwind (by removing the .postcssrc file) will allow the :global operator to be handled without encountering the error.

The error message:

% parcel ./index.html --port=4000
Server running at http://localhost:4000

@parcel/transformer-css: Unsupported pseudo class or element: global

馃帥 Configuration

.postcssrc

{
  "plugins": {
    "tailwindcss": true
  }
}

tailwindcss.config.js

/** @type {import('tailwindcss').Config} */
module.exports = {
    content: [
      "./**/*.{html,js,ts,jsx,tsx}",
    ],
    theme: {
      extend: {},
    },
    plugins: [],
  }

package.json

{
  "name": "parcel-tailwind",
  "version": "1.0.0",
  "description": "",
  "source": "index.html",
  "scripts": {
    "start": "parcel ./index.html --port=4000"
  },
  "keywords": [],
  "author": "",
  "license": "ISC",
  "devDependencies": {
    "@parcel/transformer-sass": "^2.10.3",
    "parcel": "^2.10.3",
    "postcss": "^8.4.32",
    "postcss-modules": "^4.3.1",
    "process": "^0.11.10",
    "react": "^18.2.0",
    "react-dom": "^18.2.0",
    "tailwindcss": "^3.3.6"
  }
}

馃 Expected Behavior

No warning and it should able to handle :global operator to use with tailwindcss

馃槸 Current Behavior

It show warning and it can not use the :global operator

馃拋 Possible Solution

no idea. sorry.

馃敠 Context

I have a project using CSS module and would like to migrate to tailwind but it is not a single pass process. I am seeking a solution to run tailwind and CSS module together in a period and migrate step by step.

馃捇 Code Sample

Download the example project at : parcel-tailwind.zip

Uncompress the file and then run :

% cd parcel-tailwind
% npm install
% npm start

> parcel-tailwind@1.0.0 start
> parcel ./index.html --port=4000

Server running at http://localhost:4000

@parcel/transformer-css: Unsupported pseudo class or element: global

  /Users/benlau/tmp/parcel-tailwind 2/styles.module.scss:6:3
    5 | 
  > 6 | :global .text2 {
  >   |   ^
    7 |     font-size: 1.25rem; /* 20px */
    8 |     line-height: 1.75rem; /* 28px */

Remove the .postcssrc will complains Unknown at rule: @tailwind but the :global works.

馃實 Your Environment

Software Version(s)
Parcel 2.10.3
Node v16.17.0
npm/Yarn 8.15.0
Operating System MacOS Sonoma 14
@benlau
Copy link
Author

benlau commented Feb 25, 2024

Instead of writing in

:global .text2 {

just write it in

:global(.text2) {

could fix the issue.

@benlau benlau closed this as completed Feb 25, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant