postcss-use ![Build Status](https://camo.githubusercontent.com/b2df96262fd68b2ed8d9a7c4c63fa65e320cdabbfc3d04e2faf81dffb22d0af6/68747470733a2f2f7472617669732d63692e6f72672f706f73746373732f706f73746373732d7573652e7376673f6272616e63683d6d6173746572)
Enable PostCSS plugins directly in your stylesheet.
With npm do:
npm install postcss-use --save
Both hash maps and arrays are supported; note that functions are not, for
security reasons. A hash map uses the CSS format of
option: value; option2: value2
, but please note that values must be valid
JSON syntax. For example if a module takes a string option, it must be wrapped
in quotation marks.
With postcss-discard-comments:
@use postcss-discard-comments(removeAll: true);
/*! test */
h1 {
color: red
}
You may also use configuration blocks that are more CSS-like. Note that array options cannot be parsed by this method.
@use postcss-discard-comments {
removeAll: true
}
h1 {
color: red
}
Type: array|string
Required option.
You must specify this array of postcss plugins to use, for security purposes. This prevents malicious usage of postcss-use in browser environments.
postcss([ use({ modules: ['autoprefixer', 'cssnano', 'cssnext']}) ]);
Note that you may also set this option to '*'
to disable whitelisting of
modules. This is not recommended for environments where you may be accepting
arbitrary user input; use at your own risk.
Type: boolean
(default: false
)
Set this to true in order to resolve plugins relative to the file that referenced them. This enables the usage of different versions of the same plugin, for instance.
postcss([ use({ resolveFromFile: true, modules: '*' }) ]);
Type: object
(default: {}
)
Default options for plugins, keyed by plugin name. If both the default and the specified options are objects, they are merged. Otherwise, the options specified in the CSS are used.
postcss([
use({
modules: '*',
options: {
autoprefixer: {
browsers: ['> 1%', 'IE 7']
}
}
})
]);
See the PostCSS documentation for examples for your environment.
Thanks goes to these wonderful people (emoji key):
Ben Briggs 💻 📖 👀 |
Jonathan Neal 💻 |
一丝 💻 |
Maxime Thirouin 📖 |
Bogdan Chadkin 📖 👀 |
Espen Hovlandsdal 💻 |
Andrey Sitnik 👀 |
---|
This project follows the all-contributors specification. Contributions of any kind welcome!
MIT © Ben Briggs