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’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[bug] :deep Compilation error #871

Open
lzxb opened this issue Dec 13, 2024 · 10 comments
Open

[bug] :deep Compilation error #871

lzxb opened this issue Dec 13, 2024 · 10 comments

Comments

@lzxb
Copy link

lzxb commented Dec 13, 2024

Less source code

.faq-desc :deep(.ui-collapse) {
  &-item-content {
    border-bottom-width: 0;
  }
}

Compile into CSS

.faq-desc :deep(.ui-collapse) {
  border-bottom-width: 0;
}
.faq-desc :deep(.ui-collapse)-item-content {
  border-bottom-width: 0;
}

Will report an error,in "lightningcss": "^1.28.2",

import { transform } from 'lightningcss';

transform({
  filename: 'style.css',
  code: Buffer.from(`
.faq-desc :deep(.ui-collapse) {
  border-bottom-width: 0;
}
.faq-desc :deep(.ui-collapse)-item-content {
  border-bottom-width: 0;
}

`),
  minify: true,
  sourceMap: true
});
@lzxb lzxb changed the title :deep Compilation error [bug] :deep Compilation error Dec 13, 2024
@devongovett
Copy link
Member

Shouldn't that syntax be compiled by Vue before it reaches lightningcss? That is not valid CSS syntax.

@lzxb
Copy link
Author

lzxb commented Dec 17, 2024

Vue loader always handles it last

      {
        test: /\.less$/,
        use: ['vue-style-loader', 'css-loader', 'less-loader'],
        type: 'javascript/auto',
      },

@devongovett
Copy link
Member

Why? Shouldn't it run first?

@lzxb
Copy link
Author

lzxb commented Dec 22, 2024

Rspack related documentation always requires this to be written.

@lzxb
Copy link
Author

lzxb commented Dec 22, 2024

See detail: https://rspack.dev/guide/tech/vue#vue-3

@dflock
Copy link

dflock commented Jan 14, 2025

I've started seeing this since upgrading to Vite 6.x, while using lightningcss. My relevant vite.config.ts look like this:

  css: {
    transformer: 'lightningcss',
  },
  build: {
    cssMinify: 'lightningcss',
  }

and I see this when running dev or build:

[vite:css][lightningcss] 'deep' is not recognized as a valid pseudo-class. Did you mean '::deep' (pseudo-element) or is this a typo?
1  |
2  |  :deep(.code_header) {
   |        ^
3  |    display: none;
4  |  }

It looks like vitejs/vite#495 didn't include this?

@devongovett
Copy link
Member

Again, why is this not being compiled to valid CSS before reaching Lightning CSS?

@amir20
Copy link

amir20 commented Jan 16, 2025

This is happening to me as well. I am also using the new Vite 6.x. My configuration is very minimal:

import { defineConfig } from "vite";
import Vue from "@vitejs/plugin-vue";
import SVGLoader from "vite-svg-loader";
import UnoCSS from "unocss/vite";
import WebfontDownload from "vite-plugin-webfont-dl";

export default defineConfig({
  css: {
    transformer: "lightningcss",
  },
  plugins: [Vue(), UnoCSS(), SVGLoader(), WebfontDownload()],
});

It sounds like from what @devongovett is saying is that Vue needs to run first and then lightning CSS. But that doesn't seem like it is happening.

Here is the error:

[vite:css][lightningcss] 'deep' is not recognized as a valid pseudo-class. Did you mean '::deep' (pseudo-element) or is this a typo?
18 |    }
19 |
20 |    :deep(.wave:nth-of-type(4)) {
   |          ^
21 |      fill: #0fb9b1;
22 |    }

I am using :deep in the a different project with tailwind@v4-beta and does seem to be ok.

@devongovett
Copy link
Member

Has anyone filed an issue on the vite side yet? Seems like the problem is over there

@amir20
Copy link

amir20 commented Jan 17, 2025

Created vitejs/vite-plugin-vue#507

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

4 participants