1

When including css with my webpack build, i get the following error:

ERROR in ./~/bootstrap/dist/css/bootstrap.css
Module parse failed:     /Users/myuser/Projects/project/node_modules/bootstrap/dist/css/bootstrap.css Unexpected token (8:5)
You may need an appropriate loader to handle this file type.
|  */
| /*! normalize.css v5.0.0 | MIT License | github.com/necolas/normalize.css */
| html {
|   font-family: sans-serif;
|   line-height: 1.15;
 @ ./assets/js/index.js 33:4-47
 @ multi webpack-dev-server/client?http://0.0.0.0:3000 webpack/hot/only-dev-server ./assets/js/index

The offending line in my index.js is: import 'bootstrap/dist/css/bootstrap.css'

My webpack.config.js looks like this: https://gist.github.com/colde/a0db7ca1a2d0a4596bc10241a6c55740

1
  • Shot in the dark, but in your CSS section, try this loader: loader:'style!css!' Commented Feb 7, 2017 at 20:04

1 Answer 1

2

In your webpack config you define the css loader as follows:

{
  test: /\.css$/,
  exclude: /(node_modules|bower_components)/,
  loader: "style-loader!css-loader"
}

Because bootstrap is a module you installed either from npm or bower, it is either in the node_modules or the bower_compoents directory. But you're excluding both from the loader and therefore webpack tells you that you need to configure an appropriate loader for it. Simply remove the exclude option to make it work correctly:

{
  test: /\.css$/,
  loader: "style-loader!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.