From 0694959e50c7114fd6a6e8f09ed27f810c7195cb Mon Sep 17 00:00:00 2001 From: Jake Lee Kennedy Date: Fri, 3 Jan 2025 13:15:38 +0000 Subject: [PATCH] fiddle with terser --- src/init/consented/prepare-prebid.ts | 2 +- webpack.config.mjs | 18 +++++++----------- 2 files changed, 8 insertions(+), 12 deletions(-) diff --git a/src/init/consented/prepare-prebid.ts b/src/init/consented/prepare-prebid.ts index a08987a6e..54d048ecd 100644 --- a/src/init/consented/prepare-prebid.ts +++ b/src/init/consented/prepare-prebid.ts @@ -35,7 +35,7 @@ const prebidVersion = () => { const loadPrebid = async (framework: ConsentFramework): Promise => { if (shouldLoadPrebid()) { await import( - /* webpackChunkName: "Prebid.js" */ + /* webpackChunkName: "[request]" */ `@guardian/prebid.js/build/dist/${prebidVersion()}/prebid` ); prebid.initialise(window, framework); diff --git a/webpack.config.mjs b/webpack.config.mjs index 855518e66..fba1f796d 100644 --- a/webpack.config.mjs +++ b/webpack.config.mjs @@ -1,5 +1,6 @@ import { join } from 'path'; import CircularDependencyPlugin from 'circular-dependency-plugin'; +import TerserPlugin from 'terser-webpack-plugin'; /** * @type {import('webpack').Configuration} @@ -31,21 +32,11 @@ const config = { rules: [ { test: /\.[jt]sx?|mjs$/, - exclude: { - and: [/node_modules/], - not: [ - // Include all @guardian modules, except automat-modules and prebid.js - /@guardian\/(?!(automat-modules|prebid\.js))/, - // Include the dynamic-import-polyfill - /dynamic-import-polyfill/, - ], - }, use: [ { loader: 'swc-loader', options: { $schema: 'http://json.schemastore.org/swcrc', - minify: true, jsc: { parser: { syntax: 'typescript', @@ -78,7 +69,12 @@ const config = { }), ], optimization: { - minimize: false, // we use swc-loader to minify + minimize: true, // we use swc-loader to minify + minimizer: [ + new TerserPlugin({ + minify: TerserPlugin.swcMinify, + }), + ], }, };