๐บ๏ธ Vanilla Extract #5015
Replies: 1 comment 3 replies
-
What does the type signature of
Agreed, though I don't think support for that should be a blocker for initial release. Consumers should be able to manually prefix things in most cases if they need it (not ideal obviously, but it's just a separate step in the release plan).
I think that config should probably be used universally for anything we bundle. That's kind of the whole idea behind browserslist -- you tell me what browsers you want to target, now your bundlers know what sort of transforms they should do. esbuild gives us the That said, if we wanted to support browserslist only for CSS, it seems to me we should do that for anything compiled from module.exports = {
future: {
unstable_cssBundle: {
cssModules: true,
vanillaExtract: true, // could also be a config option, eg: { identifiers: 'debug' },
autoprefixer: {
overrideBrowserslist: [], // same API as the postcss plugin here
},
},
},
}; |
Beta Was this translation helpful? Give feedback.
-
Vanilla Extract
Summary
This proposal aims to add built-in support for Vanilla Extract, building on top of the CSS bundling architecture introduced with CSS Modules.
Motivation
Many Remix consumers have been asking for Vanilla Extract support so that they can write static CSS in TypeScript.
Typically this is achieved by installing and configuring a bundler plugin, but since Remix doesn't expose the compiler to consumers, there's no way for them to achieve this. To avoid opening up the compiler to consumers, we're opting to include built-in support so you can just start writing
.css.ts
/.css.js
files without needing to set up any plugins.Usage
CSS bundling would first need to be set up, if it isn't already:
Then you'd need to install the core Vanilla Extract styling package since it's imported in your app code.
Then you'd need to enable the feature flag in your
remix.config.js
.Vanilla Extract is then opt-in via the file extension
.css.ts
/.css.js
. Any code within these files will be executed at build time.To be consistent with the rest of your app code, we need to ensure that asset imports work the same, e.g.
Open questions
Autoprefixing
How do we handle autoprefixing? This is usually achieved by providing a custom
processCss
function to the bundler plugin, but this option isn't exposed to consumers in our implementation.I think the ideal would be to handle it automatically based on the presence of a browserslist config, similar to @brophdawg11's .browserslistrc support proposal. This raises questions around sequencing thoughโis it okay for browserslist config to only be supported for Vanilla Extract initially? Or do we need to add built-in autoprefixing before we add Vanilla Extract support? Either way, I've added a proposal for built-in CSS autoprefixing.
Alternatively, we could ship an MVP solution, e.g. autoprefix Vanilla Extract styles using theActually, scratch that, this would break styles for end users in old browsers that don't support ES modules who are being given a fallback non-JS experience.supports es6-module
query, which in the future would serve as the default when a browserslist config isn't detected.We could also just do nothing for now and force consumers to manually prefix their styles, but this doesn't seem great to me.
Beta Was this translation helpful? Give feedback.
All reactions