I have a Wordpress theme that I'm migrating from gulp to webpack. I'm having a heck of a time with it not compiling SASS files. It's watching and compiling the JS file just fine but SASS files won't compile into a CSS. Here's my webpack-config.js
const path = require('path');
const UglifyJSPlugin = require('uglifyjs-webpack-plugin');
const MiniCssExtractPlugin = require('mini-css-extract-plugin');
module.exports = {
entry: ['./js/app.js', './sass/style.scss'],
plugins: [
new UglifyJSPlugin(),
new MiniCssExtractPlugin({
filename: 'style.min.css',
chunkFilename: "[name].css"
})
],
output: {
filename: 'app-compiled.min.js',
path: path.resolve(__dirname, 'js/assets')
},
optimization: {
splitChunks: {
chunks: 'all'
}
},
module: {
rules: [
{
test: /\.(scss)$/,
use: [
MiniCssExtractPlugin.loader,
'url-loader',
'css-loader',
'sass-loader'
]
},
]
}
};
My end goal is to have the css and js in separate files. I thought the optimization
was supposed to take care of that, but it's not. From other forms, the MiniCssExtractPlugin plugin needs to be right before the css-loader
but if I do that, I get a bunch of unresolved font and img errors from within the SCSS files. With the Mini in the use, it doesn't compile and I get a...
const resource = this._identifier.split('!').pop();
^
TypeError: Cannot read property 'split' of undefined
Without it, the files get watched but doesn't compile anywhere. I just need the SASS to compile. Help!!!