joeeames / WebpackFundamentalsCourse

272 stars 122 forks source link

extract text plugin no longer takes multiple arguments #13

Open JamesDaniel opened 7 years ago

JamesDaniel commented 7 years ago

extract-text-webpack-plugin's extract() function now takes a single array or an object as an argument.

So code that used to look like this:

        loaders: [
            {
                test: /\.css$/,
                exclude: /node_modules/,
                loader: ExtractTextPlugin.extract("style-loader", "css-loader")
            },
            {
                test: /\.less$/,
                exclude: /node_modules/,
                loader: ExtractTextPlugin.extract("style-loader", "css-loader!sass-loader")
            }
        ]

Should now look like this:

        loaders: [
            {
                test: /\.css$/,
                exclude: /node_modules/,
                loader: ExtractTextPlugin.extract({
                    fallback: "style-loader",
                    use: "css-loader"
                })
            },
            {
                test: /\.less$/,
                exclude: /node_modules/,
                loader: ExtractTextPlugin.extract({
                    fallback: "style-loader",
                    use: "css-loader!sass-loader"
                })
            }
        ]

The solution for this was found in the documentation: https://github.com/webpack-contrib/extract-text-webpack-plugin/blob/master/README.md

This problem was encountered in the pluralsight course on webpack: https://app.pluralsight.com/player?course=webpack-fundamentals&author=joe-eames&name=webpack-fundamentals-m4&clip=5&mode=live

chrispickford commented 6 years ago

Spent an hour troubleshooting this and came to the same resolution you did. Would be great if this was included on the README.