Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Autoprefixer doesn't work in create-react-app while using sass

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.

like image 708
Ruby Avatar asked Feb 03 '19 18:02

Ruby


People also ask

Does create react app use Autoprefixer?

Autoprefixer doesn't work in create-react-app while using sass.

Does Sass use Autoprefixer?

Autoprefixer can be easily integrated with Sass and Stylus, since it runs after CSS is already compiled.

Does create react app support Sass?

If you use the create-react-app in your project, you can easily install and use Sass in your React projects.

Does create react app support PostCSS 8?

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.


1 Answers

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.

like image 84
Derek Nguyen Avatar answered Oct 23 '22 10:10

Derek Nguyen