const path = require('path');
const HtmlPlugin = require('html-webpack-plugin');
const MiniCssExtractPlugin = require('mini-css-extract-plugin');
const { CleanWebpackPlugin } = require('clean-webpack-plugin');
module.exports = {
mode: "development",
devtool: 'source-map',
entry: {
main: './src/main.js'
},
output: {
filename: 'js/[name].[hash].js',
path: path.resolve(__dirname, 'dist'),
},
plugins: [
new CleanWebpackPlugin(),
new HtmlPlugin({
template: "./src/index.html"
}),
new MiniCssExtractPlugin({
filename: 'css/[name].[hash].css'
}),
],
module: {
rules: [
{
test: /\.s[ac]ss$/i,
use: [
MiniCssExtractPlugin.loader, // extract css to file
{
loader: 'css-loader',
options: {
modules: {
localIdentName: '[sha1:hash:hex:4]'
}
}
},
"sass-loader", // Compiles Sass to CSS
],
},
],
}
};