I'm using create-react-app and I'm using ".scss" files to style the app, and according to the documentation, autoprefixer should work automatically ... https://facebook.github.io/create-react-app/docs/post-processing-css
Here's my "index.scss" file ...
/* autoprefixer grid: on */
@import "./app/css/reset";
@import "./app/css/variables";
@import "./app/css/mixins";
@import "./app/css/global";
@import "./app/css/form";
It just imports a bunch of other ".scss" files.
And here's the "index.js" file ...
import React from "react";
import ReactDOM from "react-dom";
import * as serviceWorker from "./serviceWorker";
import { BrowserRouter as Router } from "react-router-dom";
import { Provider } from "react-redux";
import "./index.scss";
import App from "./App";
import { configureStore } from "./app/store/configureStore";
const store = configureStore();
ReactDOM.render(
<Provider store={store}>
<Router>
<App />
</Router>
</Provider>,
document.getElementById("root")
);
serviceWorker.unregister();
And here's the [browserslist] in package.json file ...
"browserslist": [
"last 1 version",
"> 1%",
"maintained node versions",
"not dead"
]
What am I doing wrong here? Whenever I inspect the CSS I can't see any autoprefixing happening.
Autoprefixer doesn't work in create-react-app while using sass.
Autoprefixer can be easily integrated with Sass and Stylus, since it runs after CSS is already compiled.
If you use the create-react-app in your project, you can easily install and use Sass in your React projects.
From what I've found, create-react-app does not support PostCSS 8 yet, see: https://github.com/postcss/postcss/wiki/PostCSS-8-for-end-users.
Your browserlist setting is really modern. This means many of the css prefixes are no longer necessary. Try something like
"browserslist": [
"since 2010" // support all browsers & versions released since 2010
]
and you should start to see autoprefixer kicking in.
Here's the list of queries you can make.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With