0

I am trying to import my css file and I keep getting this error. Cannot find module './style.css'. I modified my webpack.config.js with no luck. Please any guidance or help is appreciated. Yes, Home.js and style.css are in the same directory.

webpack.config.js

...module: {
    rules: [
      {
        test: /.js$/,
        loader: 'babel-loader',
        include: path.join(__dirname, 'app'),
        exclude: /node_modules/,
        query: {
          presets: ['es2015', 'react', 'stage-1']
        }
      },
      {
        test: /\.css$/,
        loader: ExtractTextPlugin.extract('style-loader', 'css-loader')
      }
    ]
}...

style.css

body {
  background-color: #000000;
  margin: 0px;
}

Home.js

import './style.css'

1 Answer 1

1

According to doc this should work;

...module: {
    rules: [
      ...
      {
        test: /\.css$/,
        use: ExtractTextPlugin.extract({
          fallback: 'style-loader',
          use: ['css-loader']
        })
      }
    ]
}...
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.