Gathering detailed insights and metrics for @oat-sa/postcss-preset-env
Gathering detailed insights and metrics for @oat-sa/postcss-preset-env
Gathering detailed insights and metrics for @oat-sa/postcss-preset-env
Gathering detailed insights and metrics for @oat-sa/postcss-preset-env
Convert modern CSS into something browsers understand
npm install @oat-sa/postcss-preset-env
Typescript
Module System
Min. Node Version
Node Version
NPM Version
CSS (64.95%)
JavaScript (35.05%)
Total Downloads
0
Last Day
0
Last Week
0
Last Month
0
Last Year
0
CC0-1.0 License
2,211 Stars
114 Commits
90 Forks
30 Watchers
3 Branches
21 Contributors
Updated on Jul 17, 2025
Latest Version
7.0.0
Package Id
@oat-sa/postcss-preset-env@7.0.0
Size
35.82 kB
NPM Version
6.14.4
Node Version
10.20.1
Published on
Sep 02, 2020
Cumulative downloads
Total Downloads
Last Day
0%
NaN
Compared to previous day
Last Week
0%
NaN
Compared to previous week
Last Month
0%
NaN
Compared to previous month
Last Year
0%
NaN
Compared to previous year
37
PostCSS Preset Env lets you convert modern CSS into something most browsers can understand, determining the polyfills you need based on your targeted browsers or runtime environments.
1npm install postcss-preset-env
1@custom-media --viewport-medium (width <= 50rem); 2@custom-selector :--heading h1, h2, h3, h4, h5, h6; 3 4:root { 5 --mainColor: #12345678; 6} 7 8body { 9 color: var(--mainColor); 10 font-family: system-ui; 11 overflow-wrap: break-word; 12} 13 14:--heading { 15 background-image: image-set(url(img/heading.png) 1x, url(img/heading@2x.png) 2x); 16 17 @media (--viewport-medium) { 18 margin-block: 0; 19 } 20} 21 22a { 23 color: rgb(0 0 100% / 90%); 24 25 &:hover { 26 color: rebeccapurple; 27 } 28} 29 30/* becomes */ 31 32:root { 33 --mainColor: rgba(18, 52, 86, 0.47059); 34} 35 36body { 37 color: rgba(18, 52, 86, 0.47059); 38 color: var(--mainColor); 39 font-family: system-ui, -apple-system, BlinkMacSystemFont, Segoe UI, Roboto, Oxygen, Ubuntu, Cantarell, Droid Sans, Helvetica Neue; 40 word-wrap: break-word; 41} 42 43h1, h2, h3, h4, h5, h6 { 44 background-image: url(img/heading.png); 45} 46 47@media (-webkit-min-device-pixel-ratio: 2), (min-resolution: 192dpi) { 48 h1, h2, h3, h4, h5, h6 { 49 background-image: url(img/heading@2x.png) 50 } 51} 52 53@media (max-width: 50rem) { 54 h1, h2, h3, h4, h5, h6 { 55 margin-top: 0; 56 margin-bottom: 0; 57 } 58} 59 60a { 61 color: rgba(0, 0, 255, 0.9) 62} 63 64a:hover { 65 color: #639; 66}
Without any configuration options, PostCSS Preset Env enables Stage 2 features and supports all browsers.
Add PostCSS Preset Env to your project:
1npm install postcss-preset-env --save-dev
Use PostCSS Preset Env to process your CSS:
1const postcssPresetEnv = require('postcss-preset-env'); 2 3postcssPresetEnv.process(YOUR_CSS /*, processOptions, pluginOptions */);
Or use it as a PostCSS plugin:
1const postcss = require('postcss'); 2const postcssPresetEnv = require('postcss-preset-env'); 3 4postcss([ 5 postcssPresetEnv(/* pluginOptions */) 6]).process(YOUR_CSS /*, processOptions */);
PostCSS Preset Env runs in all Node environments, with special instructions for:
Node | PostCSS CLI | Webpack | Create React App | Gulp | Grunt | Rollup |
---|
The stage
option determines which CSS features to polyfill, based upon their
stability in the process of becoming implemented web standards.
1postcssPresetEnv({ stage: 0 })
The stage
can be 0
(experimental) through 4
(stable), or false
. Setting
stage
to false
will disable every polyfill. Doing this would only be useful
if you intended to exclusively use the features
option.
Without any configuration options, PostCSS Preset Env enables Stage 2 features.
The features
option enables or disables specific polyfills by ID. Passing
true
to a specific feature ID will enable its polyfill, while passing false
will disable it. List of IDs
1postcssPresetEnv({
2 /* use stage 3 features + css nesting rules */
3 stage: 3,
4 features: {
5 'nesting-rules': true
6 }
7})
Passing an object to a specific feature ID will both enable and configure it.
1postcssPresetEnv({
2 /* use stage 3 features + css color-mod (warning on unresolved) */
3 stage: 3,
4 features: {
5 'color-mod-function': { unresolved: 'warn' }
6 }
7})
Any polyfills not explicitly enabled or disabled through features
are
determined by the stage
option.
The browsers
option determines which polyfills are required based upon the
browsers you are supporting.
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.
1postcssPresetEnv({ browsers: 'last 2 versions' })
If not valid browserslist configuration is specified, the default browserslist query will be used.
The insertBefore
and insertAfter
keys allow 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 or after certain polyfills.
Both insertBefore
and insertAfter
support chaining one or multiple plugins.
1import postcssSimpleVars from 'postcss-simple-vars';
2
3postcssPresetEnv({
4 insertBefore: {
5 'all-property': postcssSimpleVars
6 }
7})
PostCSS Preset Env includes autoprefixer and browsers
option
will be passed to it automatically.
Specifying the autoprefixer
option enables passing
additional options
into autoprefixer.
1postcssPresetEnv({ 2 autoprefixer: { grid: true } 3})
Passing autoprefixer: false
disables autoprefixer.
The preserve
option determines whether all plugins should receive a
preserve
option, which may preserve or remove otherwise-polyfilled CSS. By
default, this option is not configured.
1postcssPresetEnv({
2 preserve: false // instruct all plugins to omit pre-polyfilled CSS
3});
The importFrom
option specifies sources where variables like Custom Media,
Custom Properties, Custom Selectors, and Environment Variables can be imported
from, which might be CSS, JS, and JSON files, functions, and directly passed
objects.
1postcssPresetEnv({
2 /*
3 @custom-media --small-viewport (max-width: 30em);
4 @custom-selector :--heading h1, h2, h3;
5 :root { --color: red; }
6 */
7 importFrom: 'path/to/file.css'
8});
Multiple sources can be passed into this option, and they will be parsed in the order they are received. JavaScript files, JSON files, functions, and objects will use different namespaces to import different kinds of variables.
1postcssPresetEnv({ 2 importFrom: [ 3 /* 4 @custom-media --small-viewport (max-width: 30em); 5 @custom-selector :--heading h1, h2, h3; 6 :root { --color: red; } 7 */ 8 'path/to/file.css', 9 10 /* module.exports = { 11 customMedia: { '--small-viewport': '(max-width: 30em)' }, 12 customProperties: { '--color': 'red' }, 13 customSelectors: { ':--heading': 'h1, h2, h3' }, 14 environmentVariables: { '--branding-padding': '20px' } 15 } */ 16 'and/then/this.js', 17 18 /* { 19 "custom-media": { "--small-viewport": "(max-width: 30em)" } 20 "custom-properties": { "--color": "red" }, 21 "custom-selectors": { ":--heading": "h1, h2, h3" }, 22 "environment-variables": { "--branding-padding": "20px" } 23 } */ 24 'and/then/that.json', 25 26 { 27 customMedia: { '--small-viewport': '(max-width: 30em)' }, 28 customProperties: { '--color': 'red' }, 29 customSelectors: { ':--heading': 'h1, h2, h3' }, 30 environmentVariables: { '--branding-padding': '20px' } 31 }, 32 () => { 33 const customMedia = { '--small-viewport': '(max-width: 30em)' }; 34 const customProperties = { '--color': 'red' }; 35 const customSelectors = { ':--heading': 'h1, h2, h3' }; 36 const environmentVariables = { '--branding-padding': '20px' }; 37 38 return { customMedia, customProperties, customSelectors, environmentVariables }; 39 } 40 ] 41});
The exportTo
option specifies destinations where variables like Custom Media,
Custom Properties, Custom Selectors, and Environment Variables can be exported
to, which might be CSS, JS, and JSON files, functions, and directly passed
objects.
1postcssPresetEnv({
2 /*
3 @custom-media --small-viewport (max-width: 30em);
4 @custom-selector :--heading h1, h2, h3;
5 :root { --color: red; }
6 */
7 exportTo: 'path/to/file.css'
8});
Multiple destinations can be passed into this option as well, and they will be parsed in the order they are received. JavaScript files, JSON files, and objects will use different namespaces to import different kinds of variables.
1const cachedObject = {}; 2 3postcssPresetEnv({ 4 exportTo: [ 5 /* 6 @custom-media --small-viewport (max-width: 30em); 7 @custom-selector :--heading h1, h2, h3; 8 :root { --color: red; } 9 */ 10 'path/to/file.css', 11 12 /* module.exports = { 13 customMedia: { '--small-viewport': '(max-width: 30em)' }, 14 customProperties: { '--color': 'red' }, 15 customSelectors: { ':--heading': 'h1, h2, h3' }, 16 environmentVariables: { '--branding-padding': '20px' } 17 } */ 18 'and/then/this.js', 19 20 /* { 21 "custom-media": { "--small-viewport": "(max-width: 30em)" } 22 "custom-properties": { "--color": "red" }, 23 "custom-selectors": { ":--heading": "h1, h2, h3" }, 24 "environment-variables": { "--branding-padding": "20px" } 25 } */ 26 'and/then/that.json', 27 28 cachedObject, 29 variables => { 30 if ('customProperties' in variables) { 31 // do something special with customProperties 32 } 33 34 Object.assign(cachedObject, variables); 35 } 36 ] 37});
No vulnerabilities found.
Reason
no binaries found in the repo
Reason
no dangerous workflow patterns detected
Reason
0 existing vulnerabilities detected
Reason
license file detected
Details
Reason
Found 11/16 approved changesets -- score normalized to 6
Reason
project is archived
Details
Reason
detected GitHub workflow tokens with excessive permissions
Details
Reason
dependency not pinned by hash detected -- score normalized to 0
Details
Reason
no effort to earn an OpenSSF best practices badge detected
Reason
project is not fuzzed
Details
Reason
branch protection not enabled on development/release branches
Details
Reason
security policy file not detected
Details
Reason
SAST tool is not run on all commits -- score normalized to 0
Details
Score
Last Scanned on 2025-07-14
The Open Source Security Foundation is a cross-industry collaboration to improve the security of open source software (OSS). The Scorecard provides security health metrics for open source projects.
Learn More