Adds vendor prefixes to inline styles in React elements through autoprefix.
$ npm install babel-plugin-react-autoprefix
.babelrc
{
"plugins": ["react-autoprefix"]
}
$ babel --plugins react-autoprefix script.js
require("babel-core").transform("code", {
plugins: ["react-autoprefix"]
});
The plugin will match style
props by default. If you want to match other props, like
styleSomething
, you can use the plugin's matcher
option, e.g. in .babelrc
:
{
"plugins": ["react-autoprefix", { matcher: /^style.*$/ }]
}