Search code examples
webpackwebpack-2

Webpack 2 - doesn't create separated CSS file


I would like to create a Webpack config file, which should transpile my .scss files to a .css file. The problem is the webpack doesn't create the style.css file. I have a core.scss which cointains 4 rows, so it should do it.

My webpack.config.js:

var path = require('path');
var ExtractTextPlugin = require("extract-text-webpack-plugin");
module.exports = {

//Entry point
entry: path.resolve(__dirname, 'assets/src/js/main.js'),

//Output
output: {
    path: path.resolve(__dirname, 'assets/dist/js'),
    filename: 'bundle.js'
},

//Modules
module: {
    rules: [
        {
            test: /\.scss$/,
            use: ExtractTextPlugin.extract({
                fallback: 'style-loader',
                use: ['css-loader', 'sass-loader']
            })
        }
    ]
},

//Plugins
plugins: [
    new ExtractTextPlugin({
        filename:'style.css'
    })
]
}

What did I make wrong? Is missing something? Thank you for your help!


Solution

  • What version of webpack are you using? Your correctly importing your scss file into at least one of your js files via import '../style/core.scss'?

    Also any errors?