-
-
Notifications
You must be signed in to change notification settings - Fork 76
final typescript conversions #712
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
Changes from all commits
864041d
6a873b5
fe3b39d
5621822
30c9136
a0af2b0
91bb5a5
4490865
444ac2e
d9fe521
f1c9e15
73d79a2
b362b71
262fa57
52dbbf3
5d6718b
bdeb1fe
a555d63
41365af
4ab9e3b
eb03cc7
0f4abed
0c8b51c
9f2e625
fcf715a
37d60a7
ed56b63
a47c6af
8c61ae1
2b56a1f
c7eb900
d2d24cd
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 |
---|---|---|
@@ -0,0 +1 @@ | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
import assert from 'assert'; | ||
import plugin from 'postcss-preset-env'; | ||
import postcss from 'postcss'; | ||
|
||
const result = await postcss([plugin()]).process(':any-link { color: blue; }').css; | ||
|
||
if (process.env.BROWSERSLIST_ENV === 'production') { | ||
assert.equal( | ||
result, | ||
':link, :visited, area[href] { color: blue; }\n' + | ||
':-moz-any-link { color: blue; }\n' + | ||
':any-link { color: blue; }', | ||
); | ||
} | ||
|
||
if (process.env.BROWSERSLIST_ENV === 'development') { | ||
assert.equal(result, ':any-link { color: blue; }'); | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
{ | ||
"name": "@csstools/e2e--browserslist--package-json", | ||
"version": "0.0.0", | ||
"private": true, | ||
"description": "Can you use PostCSS Preset Env with a browserslist in package.json?", | ||
"scripts": { | ||
"test": "BROWSERSLIST_ENV=development node ./index.mjs && BROWSERSLIST_ENV=production node ./index.mjs" | ||
}, | ||
"devDependencies": { | ||
"postcss": "^8.4.19", | ||
"postcss-preset-env": "^7.8.3" | ||
}, | ||
"browserslist": { | ||
"development": [ | ||
"chrome > 100" | ||
], | ||
"production": [ | ||
"last 1 version", | ||
"> 1%", | ||
"not dead" | ||
] | ||
} | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -54,6 +54,16 @@ export function formatStagedFeature(cssdbList, browsers, features, feature, shar | |
// postcss-preset-env : option overrides | ||
options.enableProgressiveCustomProperties = false; | ||
|
||
// https://github.com/maximkoretskiy/postcss-initial#replace | ||
if (feature.id === 'all-property' && 'preserve' in options) { | ||
options.replace = options.preserve; | ||
} | ||
|
||
// https://github.com/MattDiMu/postcss-replace-overflow-wrap/blob/ec9914e0b9473a75a5d1fe32ea4311555eb81b71/index.js#L10 | ||
if (feature.id === 'overflow-wrap-property' && 'preserve' in options) { | ||
options.method = options.preserve ? 'copy' : 'replace'; | ||
} | ||
Comment on lines
+57
to
+65
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. Going over all the options of the 3rd party plugins I found 2 that have the We now map these based on user preference for 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. Let's add this to the CHANGELOG since this is actually a fix 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. done :) |
||
|
||
if (feature.plugin.postcss && typeof feature.plugin === 'function') { | ||
plugin = feature.plugin(options); | ||
} else if (feature.plugin && feature.plugin.default && typeof feature.plugin.default === 'function' && feature.plugin.default.postcss) { | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
import type autoprefixer from 'autoprefixer'; | ||
import { pluginsOptions } from './plugins/plugins-options'; | ||
|
||
export type pluginOptions = { | ||
/** | ||
* Determine which CSS features to polyfill, | ||
* based upon their process in becoming web standards. | ||
* default: 2 | ||
*/ | ||
stage?: number | ||
|
||
/** | ||
* Determine which CSS features to polyfill, | ||
* based their implementation status. | ||
* default: 0 | ||
*/ | ||
minimumVendorImplementations?: number | ||
|
||
/** | ||
* Enable any feature that would need an extra browser library to be loaded into the page for it to work. | ||
* default: false | ||
*/ | ||
enableClientSidePolyfills?: boolean | ||
|
||
/** | ||
* PostCSS Preset Env supports any standard browserslist configuration, | ||
* which can be a `.browserslistrc` file, | ||
* a `browserslist` key in `package.json`, | ||
* or `browserslist` environment variables. | ||
* | ||
* The `browsers` option should only be used when a standard browserslist configuration is not available. | ||
*/ | ||
browsers?: string | readonly string[] | null | ||
|
||
/** | ||
* Determine whether all plugins should receive a `preserve` option, | ||
* which may preserve or remove the original and now polyfilled CSS. | ||
* Each plugin has it's own default, some true, others false. | ||
* default: _not set_ | ||
*/ | ||
preserve?: boolean | ||
|
||
/** | ||
* [Configure autoprefixer](https://github.com/postcss/autoprefixer#options) | ||
*/ | ||
autoprefixer?: autoprefixer.Options | ||
|
||
/** | ||
* Enable or disable specific polyfills by ID. | ||
* Passing `true` to a specific [feature ID](https://github.com/csstools/postcss-plugins/blob/main/plugin-packs/postcss-preset-env/FEATURES.md) will enable its polyfill, | ||
* while passing `false` will disable it. | ||
* | ||
* Passing an object to a specific feature ID will both enable and configure it. | ||
*/ | ||
features?: pluginsOptions | ||
|
||
/** | ||
* The `insertBefore` key allows you to insert other PostCSS plugins into the chain. | ||
* This is only useful if you are also using sugary PostCSS plugins that must execute before certain polyfills. | ||
* `insertBefore` supports chaining one or multiple plugins. | ||
*/ | ||
insertBefore?: Record<string, unknown> | ||
|
||
/** | ||
* The `insertAfter` key allows you to insert other PostCSS plugins into the chain. | ||
* This is only useful if you are also using sugary PostCSS plugins that must execute after certain polyfills. | ||
* `insertAfter` supports chaining one or multiple plugins. | ||
*/ | ||
insertAfter?: Record<string, unknown> | ||
|
||
/** | ||
* Enable debugging messages to stdout giving insights into which features have been enabled/disabled and why. | ||
* default: false | ||
*/ | ||
debug?: boolean | ||
} |
Uh oh!
There was an error while loading. Please reload this page.