const HtmlWebpackPlugin = require("html-webpack-plugin"); const packageJson = require("./package.json"); const backgroundScripts = [ // list of scripts, all origin @ ./src ]; const indexScripts = [ // list of scripts, all origin @ ./src ]; const indexCss = [ // list of scss files, all origin @ ./scss ]; const inGameNotificationScripts = [ // list of scripts, all origin @ ./src ]; const inGameNotificationCss = [ // list of scss files, all origin @ ./scss ]; module.exports = { entry: { // Vendor: a common chunk that includes all of our dependencies vendor: Object.keys(packageJson.dependencies), backgroundScripts, indexScripts, inGameNotificationScripts, indexCss, inGameNotificationCss, background: "./src/windows/background/background.js", index: "./src/windows/index/index.js", inGameNotification: "./src/windows/inGameNotification/inGameNotification.js" }, output: { filename: "[name].js", path: `${__dirname}/dist` }, devtool: "source-map", plugins: [ new HtmlWebpackPlugin({ hash: true, scriptLoading: "blocking", chunks: ["vendor", "backgroundScripts", "background"], template: "./src/windows/background/background.ejs", filename: "./background.html" // Relative to root of the application }), new HtmlWebpackPlugin({ hash: true, scriptLoading: "blocking", chunks: ["vendor", "indexCss", "indexScripts", "index"], template: "./src/windows/index/index.ejs", filename: "./index.html" // Relative to root of the application }), new HtmlWebpackPlugin({ hash: true, scriptLoading: "blocking", chunks: ["vendor", "inGameNotificationCss", "inGameNotificationScripts", "inGameNotification"], template: "./src/windows/inGameNotification/inGameNotification.ejs", filename: "./inGameNotification.html" // Relative to root of the application }) ], module: { rules: [ { test: /\.m?js$/, exclude: /(node_modules|bower_components)/, use: { loader: "babel-loader" } }, { test: /\.s?css$/i, use: [ // Creates `style` nodes from JS strings "style-loader", // Translates CSS into CommonJS "css-loader", // Compiles Sass to CSS { loader: "sass-loader", options: { sassOptions: { outputStyle: "compressed" } } } ] }, { // Images test: /\.(png|svg|webp|ico)$/i, type: "asset/resource" }, { // Fonts test: /\.(woff2)$/i, type: "asset/resource" }, { // Plugins & html test: /\.(dll|html)$/i, type: "asset/resource" } ] } };