Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cra can't support postcss-nested syntax because webpack.config.js file haven't postcss-nested module #9604

Open
melihyarikkaya opened this issue Sep 7, 2020 · 4 comments

Comments

@melihyarikkaya
Copy link

Is your proposal related to a problem?

Cra can't support postcss-nested syntax because webpack.config.js file haven't postcss-nested module.

Sample nested css in my header.module.css file

.Header {
  background: white;
  h1 {
    color: red;
  }
}

Expected behavior when compiled

.Header {
  background: white;
}
.Header h1 {
    color: red;
}

Describe the solution you'd like

The problem solved when ejected cra and adding the 'postcss-nested' module to webpack.module.js.

Can you support postcss-nested by default?

// config/webpack.config.js
// row 89
ident: 'postcss',
          plugins: () => [
            require('postcss-flexbugs-fixes'),
            require('postcss-nested'), // <----  added this line 
            require('postcss-preset-env')({
              autoprefixer: {
                flexbox: 'no-2009'
              },
              stage: 3
            }),

Describe alternatives you've considered

postcss-nesting may be an alternative.

Additional context

(Write your answer here.)

@btmnk
Copy link

btmnk commented Dec 7, 2020

Just a thought: Wouldn't it be much easier to configure postcss by using a postcss.config.js file that is created when using CRA instead of the inline options in the loader?
This way the developer can easily decide which additional features he might need without the need of ejecting.

e.g.

const postcssPresetEnv = require("postcss-preset-env");

const config = () => ({
  plugins: [
    postcssPresetEnv({
      stage: 3,
      features: {
        "nesting-rules": true,
        "custom-media-queries": true,
      },
      importFrom: "./src/ui/theme/theme.css",
    }),
  ],
});

module.exports = config;

@alesso-x
Copy link

alesso-x commented Feb 21, 2021

postcss.config.js is not supported in CRA. There is an open PR to update postcss-loader and that will allow the configuration to be added.

@kalm42
Copy link

kalm42 commented Mar 10, 2021

postcss.config.js is not supported in CRA. There is an open PR to update postcss-loader and that will allow the configuration to be added.

This would be my preferred solution.

@piotr-cz
Copy link
Contributor

At this moment loading postcss.config.js is being disabled with config: false flag here: #11717
There is a PR to remove it: #11926

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants