Options may be passed into plugins as a JSON object, an array, a hash map, oras declarations. Hash maps will follow the format ofoption: value, option2: value2.
You may also use configuration blocks that are moreCSS-like. Note that rootarray options cannot be parsed by this method.
@use postcss-discard-comments{
removeAll:true
}
Output
h1{
color:red
}
API
use(options)
options
modules
Type:array|stringRequired option.
Themodulesoption specifies a list of allowable PostCSS Plugins, expressedas aString,Array, orRegExp. By default, all plugins are disabled inorder to prevent malicious usage in browser environments.
use({
// allow plugins starting with autoprefixer, postcss, precss, and cssnano
modules:[
/^autoprefixer/,
/^postcss/,
/^precss/,
/^cssnano/
]
})
use({
// allow autoprefixer, postcss-preset-env, and postcss-flexbugs-fixes
Setting the option to"*"will allow PostCSS Use to require any plugins. Thisis not recommended for environments where you may be accepting arbitrary userinput; use at your own risk.
resolveFromFile
Type:boolean(default:false)
TheresolveFromFileoption specifies whether plugins should be resolvedrelative to the file that referenced them. This may be used to enable the usageof different versions of the same plugin. By default, it is disabled.
use({
resolveFromFile:true
})
options
Type:object(default:{})
Theoptionsoption specifies individual options for specific plugins byplugin name.