Extending Webpack

Overview

The Shopware 6 Administration uses Webpack as a static module bundler. Normally you don't need to change the Webpack configuration, but if you need to here is how to do it.

Extending the Webpack configuration

The Webpack configuration can be extended by creating the file <plugin root>/src/Resources/app/administration/build/webpack.config.js and exporting a function from it. This will return a webpack configuration object, as seen below:

<plugin root>/src/Resources/app/administration/build/webpack.config.js
const path = require('path');
module.exports = () => {
return {
resolve: {
alias: {
SwagBasicExample: path.join(__dirname, '..', 'src')
}
}
};
};

This way, the configuration is automatically loaded and then merged with the Shopware provided webpack configuration, including all other plugin webpack configurations. Merging is done with the webpackMerge library.

This merging makes it technically possible to override the Shopware provided configuration, but you shouldn't change the default configurations so that the builded core code will differ from the original builded code without your configuration, because this could break the administration, your plugin or other third-party plugins.