I have a situation when I have multiple themes in a project and every theme has it's [theme-name].scss file and [theme-name].js file which has to be compiled into [theme-name]/dist folder. So I have multiple entries with multiple outputs.
I thought I've found the simplified solution on Webpack's page here: https://v4.webpack.js.org/guides/entry-advanced/ , however only 2 js files are built into dist folder and no css. Maybe someone could tell me why it's so? Thank you.
My exact config:
const MiniCssExtractPlugin = require('mini-css-extract-plugin');
module.exports = {
mode: process.env.NODE_ENV,
entry: {
home: ['./src/js/home.js', './src/scss/home.scss'],
account: ['./src/js/account.js', './src/scss/account.scss'],
},
output: {
filename: '[name].js',
},
module: {
rules: [
{
test: /\.scss$/,
use: [
// fallback to style-loader in development
process.env.NODE_ENV !== 'production' ? 'style-loader' : MiniCssExtractPlugin.loader,
'css-loader',
'sass-loader',
],
},
],
},
plugins: [
new MiniCssExtractPlugin({
filename: '[name].css'
}),
],
};