Snackoverflow
Snackoverflow

Reputation: 828

Webpack css, sass and styleloader

I'm new to Webpack so it is probably an easy fix, but I can't seem to find it.

I've made a small scss file to see if Webpack can compile it:

$color: #00000;

* {
    background-color: $color;
}

However, when I run webpack-dev-server it gives me this error: Invalid CSS after "$color:": expected expression (e.g. 1px, bold), was "#00000;"

I think it has something to do with ExtractTextPlugin, but I have followed the example and I can't find the problem

This is my webpack.config:

const ExtractTextPlugin = require('extract-text-webpack-plugin');

const extractSass = new ExtractTextPlugin({
    filename: "[name].[contenthash].css",
    disable: process.env.NODE_ENV === "development"
});

module.exports = {
    context: __dirname + '/app',
    entry: './app.module.js',
    output: {
        path: __dirname + '/build',
        filename: 'bundle.js'
    },
    module: {
        rules: [
            {
                test: /\.js$/,
                exclude: /node_modules/,
                use: {
                    loader: 'babel-loader',
                    options: {
                        presets: ['env']
                    }
                }
            },
            {
                test: /\.scss$/,
                use: extractSass.extract({
                     use: ['css-loader', 'sass-loader'],
                     fallback: "style-loader"
                })
            }
        ]
    },
    plugins: [
        extractSass
    ],
    resolve: {
        alias: {
            Styles: __dirname + '/assets/styles'
        }
    }
};

Any help would be appreciated, thanks

Upvotes: 0

Views: 111

Answers (1)

user3369753
user3369753

Reputation:

#000 or #000000 instead of #00000. :-)

Upvotes: 1

Related Questions