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

Allowing global style injection into all CSS files #664

Open
nd55 opened this issue Jan 17, 2024 · 3 comments
Open

Allowing global style injection into all CSS files #664

nd55 opened this issue Jan 17, 2024 · 3 comments

Comments

@nd55
Copy link

nd55 commented Jan 17, 2024

Hello there :)

I use custom media queries in almost every project. With PostCSS, I would utilize @csstools/postcss-global-data with the following configuration to inject all custom media queries into every file, eliminating the need to import them every time.

// postcss.config.js
module.exports = {
  plugins: [
    require("@csstools/postcss-global-data")({
      files: ["./src/css/_media.css"],
    }),
    require("postcss-preset-env")({ ... }),
  ],
}

In Lightning CSS, I haven't found any alternative for injecting custom CSS into every file as I did with PostCSS. Currently, I have to manually import _media.css into every CSS file. Have I overlooked this feature, or is it not yet possible? I am using Lightning CSS in Vite projects (SvelteKit, Astro).

I would appreciate any feedback or considerations regarding the possibility of adding this as a feature.

Thanks for reading!

@nd55 nd55 changed the title Global style injection in all CSS files Allowing global style injection into all CSS files Jan 17, 2024
@ShayanTheNerd
Copy link

Hi, @devongovett

Thanks for this awesome tool! Unfortunately, I'm having the exact same issue in an Astro project. Looking for a solution or at least a workaround...

@devongovett
Copy link
Member

See answer here for a possible way to implement this #742 (comment)

@nd55
Copy link
Author

nd55 commented May 18, 2024

Thanks for your answer. Astro and Svelte are based on Vite, and unfortunately, vite does not yet support custom resolvers for its Lightning CSS integration. There already is an open issue about that, so I will keep an eye on that :)

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

3 participants