-
-
Notifications
You must be signed in to change notification settings - Fork 5.6k
Add a colorMixPolyfill option to @tailwindcss/postcss #20444
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
base: main
Are you sure you want to change the base?
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -31,7 +31,7 @@ interface CacheEntry { | |
| const cache = new QuickLRU<string, CacheEntry>({ maxSize: 50 }) | ||
|
|
||
| function getContextFromCache(postcss: Postcss, inputFile: string, opts: PluginOptions): CacheEntry { | ||
| let key = `${inputFile}:${opts.base ?? ''}:${JSON.stringify(opts.optimize)}` | ||
| let key = `${inputFile}:${opts.base ?? ''}:${JSON.stringify(opts.optimize)}:${opts.colorMixPolyfill ?? true}` | ||
| if (cache.has(key)) return cache.get(key)! | ||
| let entry = { | ||
| mtimes: new Map<string, number>(), | ||
|
|
@@ -68,12 +68,23 @@ export type PluginOptions = { | |
| * Defaults to `true`. | ||
| */ | ||
| transformAssetUrls?: boolean | ||
|
|
||
| /** | ||
| * Emit `color-mix(…)` fallbacks for browsers without `color-mix()` support | ||
| * (Safari < 16.2): a plain fallback declaration, plus a copy of the original | ||
| * declaration gated behind `@supports (color: color-mix(in lab, red, red))`. | ||
| * | ||
| * Defaults to `true`. Set this to `false` when every browser you support has | ||
| * `color-mix()`, which removes the duplicated declarations from the output. | ||
| */ | ||
| colorMixPolyfill?: boolean | ||
|
Comment on lines
+72
to
+80
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
The package README documents the existing public plugin options, but not Knowledge Base Used: PostCSS plugin Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Added in 2cd26db: a "Enabling or disabling the |
||
| } | ||
|
|
||
| function tailwindcss(opts: PluginOptions = {}): AcceptedPlugin { | ||
| let base = opts.base ?? process.cwd() | ||
| let optimize = opts.optimize ?? process.env.NODE_ENV === 'production' | ||
| let shouldRewriteUrls = opts.transformAssetUrls ?? true | ||
| let colorMixPolyfill = opts.colorMixPolyfill ?? true | ||
|
|
||
| return { | ||
| postcssPlugin: '@tailwindcss/postcss', | ||
|
|
@@ -144,7 +155,9 @@ function tailwindcss(opts: PluginOptions = {}): AcceptedPlugin { | |
| // In CSS Module files, we have to disable the `@property` polyfill since these will | ||
| // emit global `*` rules which are considered to be non-pure and will cause builds | ||
| // to fail. | ||
| polyfills: isCSSModuleFile ? Polyfills.All ^ Polyfills.AtProperty : Polyfills.All, | ||
| polyfills: | ||
| (isCSSModuleFile ? Polyfills.All ^ Polyfills.AtProperty : Polyfills.All) & | ||
| (colorMixPolyfill ? Polyfills.All : ~Polyfills.ColorMix), | ||
| }) | ||
| DEBUG && I.end('Create compiler') | ||
|
|
||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.