Webpack TypeError when going higher than 4.15

When trying to upgrade to any version of strapi higher than 4.15. I get the following error when trying to build the Admin Panel:

 Building build context
[INFO] Including the following ENV variables as part of the JS bundle:
✔ Building build context (29ms)
⠋ Building admin panel
⠹ Building admin panel/app/src/admin/webpack.config.js:6
    new webpack.DefinePlugin({

TypeError: webpack.DefinePlugin is not a constructor
    at module.exports (/app/src/admin/webpack.config.js:6:5)
    at Object.mergeConfigWithUserConfig (/app/node_modules/@strapi/admin/_internal/node/webpack/config.ts:209:14)
    at <anonymous> (/app/node_modules/@strapi/admin/_internal/node/webpack/build.ts:11:25)

I have my webpack config located at src/admin/webpack.config.js and it looks (modified of course) like this:

'use strict';

module.exports = (config, webpack) => {
    new webpack.DefinePlugin({
      SOME_VARS: {
        var_one: JSON.stringify(process.env.VAR_1),
        var_two: JSON.stringify(process.env.VAR_2),
  return config;

I need the defined env vars in the admin panel.

I think I follow the documentation by defining those variables like this in my webpack config, yet it suddenly does not build anymore.

Any help is highly appreciated! Thanks a lot!

System Information
  • Strapi Version: 4.16. or higher
  • Operating System: MacOS
  • Node Version: 20.8.0
  • Yarn Version: 3.4.1

Additional Info: It fails as soon as I update to 4.15.2

Try the newest strapi version on a clone of the project if that still breaks please open a issue on Issues · strapi/strapi · GitHub