Warm tip: This article is reproduced from stackoverflow.com, please click
bootstrap-4 css reactjs webpack webpack-4

I can't build my react with boostrap problem about css-loader

发布于 2020-03-31 22:57:57

My react index.js import bootstrap, I using Webpack 4

import React from 'react';
import ReactDOM from 'react-dom';
import './assets/css/index.css';
import App from './App';
import * as serviceWorker from './serviceWorker';
import 'bootstrap/dist/css/bootstrap.min.css';

ReactDOM.render(<App />, document.getElementById('root'));

serviceWorker.unregister();

When i run build, This error message

ERROR in ./node_modules/bootstrap/dist/css/bootstrap.min.css 6:3
Module parse failed: Unexpected token (6:3)
You may need an appropriate loader to handle this file type, currently no loaders are configured to process this file. See https://webpack.js.org/concepts#loaders

module: {
   ...
   {
      test: /\.css$/,
      exclude: /(node_modules)/,
      use: ['style-loader', 'css-loader'],
   },
   ...
}

Thank your for your help.

Questioner
TSCH
Viewed
82
Prakash Karena 2020-01-31 20:25

You excluding your node_modules causing this problem remove it from wabpack configuration.

module: {
   ...
   {
      test: /\.css$/,
      use: ['style-loader', 'css-loader']
   },
   ...
}