From 19b2c004ab9729d04ce48a624f4215e6d97dc7b5 Mon Sep 17 00:00:00 2001 From: dew326 Date: Fri, 5 Apr 2019 09:04:21 +0200 Subject: [PATCH] EZP-30406: Cannot add custom webpack config from bundle (#382) --- .gitignore | 3 +++ ez.webpack.custom.configs.js | 12 ++++++++++++ var/encore/.gitkeep | 0 webpack.config.js | 5 +++-- 4 files changed, 18 insertions(+), 2 deletions(-) create mode 100644 ez.webpack.custom.configs.js create mode 100644 var/encore/.gitkeep diff --git a/.gitignore b/.gitignore index ea2671cc..b5e44270 100644 --- a/.gitignore +++ b/.gitignore @@ -31,6 +31,9 @@ !/var/sessions /var/sessions/* !var/sessions/.gitkeep +!/var/encore +/var/encore/* +!var/encore/.gitkeep !var/SymfonyRequirements.php /vendor/ /web/bundles/ diff --git a/ez.webpack.custom.configs.js b/ez.webpack.custom.configs.js new file mode 100644 index 00000000..2245b861 --- /dev/null +++ b/ez.webpack.custom.configs.js @@ -0,0 +1,12 @@ +const path = require('path'); +const customConfigs = require('./var/encore/ez.webpack.custom.config.js'); + +module.exports = customConfigs.reduce((configs, customConfigPath) => { + let customConfig = require(customConfigPath); + + if (!Array.isArray(customConfig)) { + customConfig = [customConfig]; + } + + return [ ...configs, ...customConfig ]; +}, []); diff --git a/var/encore/.gitkeep b/var/encore/.gitkeep new file mode 100644 index 00000000..e69de29b diff --git a/webpack.config.js b/webpack.config.js index a9e5f7c8..22c5196b 100644 --- a/webpack.config.js +++ b/webpack.config.js @@ -3,6 +3,7 @@ const path = require('path'); const getEzConfig = require('./ez.webpack.config.js'); const eZConfigManager = require('./ez.webpack.config.manager.js'); const eZConfig = getEzConfig(Encore); +const customConfigs = require('./ez.webpack.custom.configs.js'); Encore.reset(); Encore.setOutputPath('web/assets/build') @@ -15,7 +16,7 @@ Encore.setOutputPath('web/assets/build') // uncomment the two lines below, if you added a new entry (by Encore.addEntry() or Encore.addStyleEntry() method) to your own Encore configuration for your project // const projectConfig = Encore.getWebpackConfig(); -// module.exports = [ eZConfig, projectConfig ]; +// module.exports = [ eZConfig, ...customConfigs, projectConfig ]; // comment-out this line if you've uncommented the above lines -module.exports = eZConfig; +module.exports = [ eZConfig, ...customConfigs ];