On node v16.x it’s working fine, but I need 12.x.
const path = require('path');
const HtmlWebpackPlugin = require('html-webpack-plugin');
const MiniCssExtractPlugin = require('mini-css-extract-plugin');
const PugPlugin = require('pug-plugin');
module.exports = {
mode: 'development',
stats: 'maximal',
entry: './src/index.ts',
output: {
path: path.resolve(__dirname, 'dist'),
filename: '[name].[contenthash].js',
clean: true,
},
resolve: {
extensions: ['.ts', '.tsx', '.js'],
},
devServer: {
static: {
directory: path.join(__dirname, 'dist'),
},
hot: true,
port: 3000,
historyApiFallback: true,
compress: true,
},
module: {
rules: [
{
test: /\.ts$/,
include: path.resolve(__dirname, 'src'),
use: [
{
loader: 'ts-loader',
options: {
configFile: path.resolve(__dirname, 'tsconfig.json'),
},
},
],
exclude: /(node_modules)/,
},
{
test: /\.s[ac]ss$/i,
use: [
MiniCssExtractPlugin.loader,
'css-loader',
'sass-loader',
],
},
{
test: /\.pug$/,
loader: PugPlugin.loader,
exclude: /(node_modules)/,
},
],
},
plugins: [
new HtmlWebpackPlugin({
template: 'src/index.html',
}),
new MiniCssExtractPlugin({
filename: '[name].[contenthash].css',
}),
],
};