Skip to content

Commit

Permalink
Update webpack.config.js
Browse files Browse the repository at this point in the history
  • Loading branch information
rvdforst committed Nov 7, 2024
1 parent bcf644d commit 7aa1b7e
Showing 1 changed file with 13 additions and 41 deletions.
54 changes: 13 additions & 41 deletions webpack.config.js
Original file line number Diff line number Diff line change
@@ -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",
Expand Down

0 comments on commit 7aa1b7e

Please sign in to comment.