const path = require('path'); const HtmlWebpackPlugin = require('html-webpack-plugin'); const pages = ["index", "aes"]; module.exports = { mode: 'development', entry: pages.reduce((config, page) => { config[page] = `./src/${page}.js`; return config; }, {}), devtool: 'inline-source-map', devServer: { static: './dist', }, output: { filename: "[name].js", path: path.resolve(__dirname, "dist"), }, optimization: { splitChunks: { chunks: "all", }, }, plugins: [].concat( pages.map( (page) => new HtmlWebpackPlugin({ inject: true, template: `./src/pages/${page}.html`, filename: `${page}.html`, chunks: [page], }) ) ), module: { rules: [ { test: /\.css$/i, use: ['style-loader', 'css-loader'], }, ], }, };