From 7aa1b7ef2ba15c1f913fe09c272b6f4687e23fc5 Mon Sep 17 00:00:00 2001 From: Rolf Date: Thu, 7 Nov 2024 16:06:09 +0100 Subject: [PATCH] Update webpack.config.js --- webpack.config.js | 54 ++++++++++++----------------------------------- 1 file changed, 13 insertions(+), 41 deletions(-) diff --git a/webpack.config.js b/webpack.config.js index d380d85..c411271 100644 --- a/webpack.config.js +++ b/webpack.config.js @@ -1,50 +1,22 @@ -const defaultConfig = require("@wordpress/scripts/config/webpack.config"); +const defaults = require("@wordpress/scripts/config/webpack.config"); const webpack = require("webpack"); -const { basename, dirname, resolve } = require("path"); -const srcDir = "src"; - -const settings = resolve(process.cwd(), "src", "settings"); -const tos = resolve(process.cwd(), "src", "tos"); -const consent = resolve(process.cwd(), "src", "consent"); -const banner = resolve(process.cwd(), "src", "banner"); -const prioritize = resolve(process.cwd(), "src", "prioritize"); +/** + * WP-Scripts Webpack config. + * + * @see https://developer.wordpress.org/block-editor/packages/packages-scripts/#provide-your-own-webpack-config + */ module.exports = { - ...defaultConfig, + ...defaults, entry: { - settings, - tos, - consent, - banner, - prioritize, - }, - output: { - path: resolve(process.cwd(), "build"), - filename: "[name].js", - clean: true, - }, - optimization: { - ...defaultConfig.optimization, - splitChunks: { - cacheGroups: { - style: { - type: "css/mini-extract", - test: /[\\/]style(\.module)?\.(pc|sc|sa|c)ss$/, - chunks: "all", - enforce: true, - name(_, chunks, cacheGroupKey) { - const chunkName = chunks[0].name; - return `${dirname(chunkName)}/${basename( - chunkName - )}.${cacheGroupKey}`; - }, - }, - default: false, - }, - }, + settings: "./src/settings/index.js", + tos: "./src/tos/index.js", + consent: "./src/consent/index.js", + banner: "./src/banner/index.js", + prioritize: "./src/prioritize/index.js", }, plugins: [ - ...defaultConfig.plugins, + ...defaults.plugins, new webpack.ProvidePlugin({ $: "jquery", jQuery: "jquery",