CSS Bundling (and dropping PostCSS as core dependency) #763
Replies: 5 comments
-
Some approaches being shared in the Lit Slack around managing global styles that might be worth keeping in mind in terms of use cases to support.
Really good issue here about trying to work with global styles and WCs - WICG/webcomponents#909 |
Beta Was this translation helpful? Give feedback.
-
Other good links |
Beta Was this translation helpful? Give feedback.
-
Hmm, with ParcelCSS being just released, if it can handle edit: looks like it can!
|
Beta Was this translation helpful? Give feedback.
-
Maybe just go with a CSS AST? |
Beta Was this translation helpful? Give feedback.
-
implemented here as part of the v0.27.0 release - #980 |
Beta Was this translation helpful? Give feedback.
-
Overview
So as part of working on https://github.com/AnalogStudiosRI/www.analogstudios.net I ran into an issue that while solved easily enough in the end, was not immediately obvious to me at the time and felt somewhat unsatisfactory after getting to understand the naunce of the issue .
As part of migrating a SPA from Angular 2+ -> Web Components (w/Lit) I ran into an issue with bundling CSS in the context of Shadow DOM and trying to recreate a design system, that I was worth tracking here. Basically, start with a component that uses a form of CSS in JS (effectively using the CSS Modules approach) that references another CSS file using
@import
.header.css
header.js
When building, the issue is that the
@import
statements are not getting processed and so when runningyarn serve
you would see 404s for these files.Proposal
It seems for now the easiest solution is the one I ended up using, which was to just add the postcss-import PostCSS plugin to the project's postcss.config.js:
Ideally it would great to drop PostCSS from the default CLI installation (it is used in rollup.config.js and figure out how to handle this on our own, especially in an ESM world where we won't need this plugin (see #606 ) , hopefully this is something we can make as first class as we do JavaScript, which may require using Rollup, but at least then we can drop some dependencies from the CLI and / or offload it to the postcss plugin.
So some high level goals to aim for off the top of my head:
import.meta.url
, Constructible Stylesheets, and CSS ModulesBeta Was this translation helpful? Give feedback.
All reactions