简体   繁体   中英

Error: No PostCSS Config found in '/home/react-project/workarea/scss'

I am trying to load scss files in my reactjs app using webpack. Here is my webpack code:

module: { 
 rules: [
  {
    test: /\.js$/,
    exclude: /node_modules/,
    use: {
      loader: 'babel-loader'
    },
  },
  {
    test: /\.(sa|sc|c)ss$/,
    use: [
      devMode ? 'style-loader' : MiniCssExtractPlugin.loader,
      'css-loader',
      'postcss-loader',
      'sass-loader',
    ],
  }
 ]
},
plugins: [
 new HtmlWebpackPlugin({
   template: './src/index.html'
 }),
 new MiniCssExtractPlugin({
   filename: devMode ? '[name].css' : '[name].[hash].css',
   chunkFilename: devMode ? '[id].css' : '[id].[hash].css',
 })
]

When I try to run this it throws me the above error.

This will be fixed if you either have postcss.config.js in root directory or inline if u have it options, For example

options: {
    plugins: (loader) => [
      require('autoprefixer')({
        browsers: [
          'last 2 versions',
          '> 1%',
        ], // browser options can be configured from https://github.com/browserslist/browserslist
      }),
    ],
  },

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM