Dileet
Dileet

Reputation: 2074

Webpack and sass

I'm having issues loading in my scss files with webpack.

I get this error:

Module build failed: 
@import 'bulma';
^
      Invalid CSS after "...load the styles": expected 1 selector or at-rule, was "content = requi..."

This is my webpack config file:

module.exports = {
  entry: "./app/App.js",
  output: {
    filename: "public/bundle.js"
  },
  module: {
    loaders: [
      {
        test: /\.jsx?$/,
        exclude: /(node_modules|bower_components)/,
        loader: 'babel',
        query: {
          presets: ['react', 'es2015']
        }
      },
      {
        test: /\.scss$/,
        loaders: ['css', 'sass', 'style']
      }
    ]
  }
};

This is main.scss:

@import 'bulma';

body {
  background-color: red;
}

and I import the file in the App.js entry point like so:

import './stylesheets/main.scss';

Any tips?

Upvotes: 0

Views: 3017

Answers (1)

Interrobang
Interrobang

Reputation: 17454

Your loaders are in the wrong order. Loaders are read right-to-left. You want to parse the SCSS into CSS, then parse CSS into Javascript, then load the parsed CSS as a style tag, so you want:

        loaders: ['style', 'css', 'sass']

Upvotes: 4

Related Questions