const path = require('path'), HtmlWebpackPlugin = require('html-webpack-plugin'), MiniCssExtractPlugin = require('mini-css-extract-plugin'); module.exports = { entry: './src/index.ts', devtool: 'inline-source-map', mode: 'development', module: { rules: [ { test: /\.tsx?$/, use: 'ts-loader', exclude: /node_modules/, }, { test: /\.s[ac]ss$/i, use: [ MiniCssExtractPlugin.loader, "css-loader", "sass-loader", ], } ], }, resolve: { extensions: ['.tsx', '.ts', '.js'], }, output: { filename: '[name].[contenthash].js', path: path.resolve(__dirname, 'dist'), clean: true, }, optimization: { runtimeChunk: 'single', splitChunks: { chunks: 'all', maxInitialRequests: Infinity, minSize: 0, cacheGroups: { vendor: { test: /[\\/]node_modules[\\/]/, name(module) { // get the name. E.g. node_modules/packageName/not/this/part.js // or node_modules/packageName const packageName = module.context.match(/[\\/]node_modules[\\/](.*?)([\\/]|$)/)[1]; // npm package names are URL-safe, but some servers don't like @ symbols return `npm.${packageName.replace('@', '')}`; }, }, }, }, }, plugins: [ new HtmlWebpackPlugin({ title: 'webdj' }), new MiniCssExtractPlugin() ], };