Jak ktoś jest ciekawy to w taki sposób udało mi się to zrobić
const path = require('path');
const HtmlWebpackPlugin = require('html-webpack-plugin');
const MiniCssExtratPlugin = require('mini-css-extract-plugin');
const devMode = process.env.NODE_ENV !== 'production'
module.exports = {
entry: './js/main.js',
output: {
filename: '[name].bundle.js',
path: path.resolve(__dirname, 'dist')
},
module: {
rules: [{
test: /\.js$/,
exclude: /node_modules/,
use: [{
loader: 'babel-loader',
options: {
presets: ['env']
}
}]
},
{
test: /\.(sa|sc|c)ss$/,
use: [
devMode ? 'style-loader' : MiniCssExtratPlugin.loader,
{
loader: "css-loader",
options: {
url: false
}
},
"sass-loader"
]
}
]
},
plugins: [
new HtmlWebpackPlugin({
template: './index.html'
}),
new MiniCssExtratPlugin({
filename: "[name].css",
chunkFilename: "[id].css"
})
]
}