There is a simple config for webpack 4
const path = require('path');
const MiniCssExtractPlugin = require('mini-css-extract-plugin');
module.exports = {
entry: {
app: './src/index.js',
},
output: {
filename: '[name].js',
path: path.resolve(__dirname, './dist'),
publicPath: '/dist',
},
plugins: [
new MiniCssExtractPlugin({
filename: '[name].css',
})
],
module: {
rules: [
{
test: /\.js$/,
loader: 'babel-loader',
exclude: '/node_modules/'
},
{
test: /\.css$/,
use: [
MiniCssExtractPlugin.loader,
'css-loader'
],
},
],
},
}
CSS-file is imported to the entry point (index.js), it is necessary to output it in the production build to a separate CSS-file (using mini-css-extract-plugin, want to try exactly this plugin, not other methods). But an error occurs: https://i.stack.imgur.com/VoqTW.png
Here is full file structure https://github.com/DazzRune/webpack4test