Skip to content

Commit ccbeb83

Browse files
committed
Update webpack.config.js for 5.0
Get `ibexaConfigManager` and `getIbexaConfig`, now absent by default, then use them, and finally add ibexaConfig to module.exports
1 parent fc09d8c commit ccbeb83

File tree

2 files changed

+26
-28
lines changed

2 files changed

+26
-28
lines changed
Lines changed: 23 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,34 +1,30 @@
1-
const Encore = require('@symfony/webpack-encore');
1+
const fs = require('fs');
22
const path = require('path');
3-
const getIbexaConfig = require('@ibexa/frontend-config/webpack-config/ibexa');
4-
const ibexaConfig = getIbexaConfig(Encore);
5-
const customConfigs = require('./ibexa.webpack.custom.configs.js');
6-
const { isReactBlockPathCreated } = require('./ibexa.webpack.config.react.blocks.js');
7-
const ibexaConfigManager = require('@ibexa/frontend-config/webpack-config/manager');
3+
const Encore = require('@symfony/webpack-encore');
4+
const getWebpackConfigs = require('@ibexa/frontend-config/webpack-config/get-configs');
5+
const customConfigsPaths = require('./var/encore/ibexa.webpack.custom.config.js');
6+
7+
const customConfigs = getWebpackConfigs(Encore, customConfigsPaths);
8+
const isReactBlockPathCreated = fs.existsSync('./assets/page-builder/react/blocks');
89

910
Encore.reset();
1011
Encore
1112
.setOutputPath('public/build/')
1213
.setPublicPath('/build')
13-
.enableStimulusBridge('./assets/controllers.json')
1414
.enableSassLoader()
15-
.enableReactPreset()
15+
.enableReactPreset((options) => {
16+
options.runtime = 'classic';
17+
})
1618
.enableSingleRuntimeChunk()
1719
.copyFiles({
1820
from: './assets/images',
1921
to: 'images/[path][name].[ext]',
20-
pattern: /\.(png|svg)$/
22+
pattern: /\.(png|svg)$/,
2123
})
22-
.configureBabel((config) => {
23-
config.plugins.push('@babel/plugin-proposal-class-properties');
24-
})
25-
26-
// enables @babel/preset-env polyfills
2724
.configureBabelPresetEnv((config) => {
2825
config.useBuiltIns = 'usage';
2926
config.corejs = 3;
30-
})
31-
;
27+
});
3228

3329
// Welcome page stylesheets
3430
Encore.addEntry('welcome-page-css', [
@@ -47,18 +43,21 @@ if (isReactBlockPathCreated) {
4743

4844
Encore.addEntry('app', './assets/app.js');
4945

50-
// Image Editor Dot Action
46+
const projectConfig = Encore.getWebpackConfig();
47+
48+
projectConfig.name = 'app';
49+
50+
/* Get ibexaConfig and ibexaConfigManager */
51+
const ibexaConfigManager = require('@ibexa/frontend-config/webpack-config/manager');
52+
const getIbexaConfig = require('@ibexa/frontend-config/webpack-config/ibexa');
53+
const ibexaConfig = getIbexaConfig();
54+
55+
/* Add entries to Admin UI layout JS */
5156
ibexaConfigManager.add({
5257
ibexaConfig,
5358
entryName: 'ibexa-admin-ui-layout-js',
5459
newItems: [ path.resolve(__dirname, './assets/random_dot/random-dot.js'), ],
5560
});
5661

57-
const projectConfig = Encore.getWebpackConfig();
58-
59-
projectConfig.name = 'app';
60-
62+
/* Add ibexaConfig to module.exports */
6163
module.exports = [ibexaConfig, ...customConfigs, projectConfig];
62-
63-
// uncomment this line if you've commented-out the above lines
64-
// module.exports = [ eZConfig, ibexaConfig, ...customConfigs ];

docs/content_management/images/extend_image_editor.md

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -32,11 +32,10 @@ Configure the new Image Editor action under the `ibexa.system.<scope>.image_edit
3232
## Add entry to the Webpack configuration
3333

3434
Once you create and configure the React component, you must add an entry to [the Webpack configuration](3_customize_the_front_page.md#configuring-webpack).
35-
In the root directory of your project, modify the `webpack.config.js` file by adding the following code:
35+
In the root directory of your project, modify the `webpack.config.js` file by adding the following code in replacement of the default `module.exports = [...customConfigs, projectConfig];`:
3636

37-
``` js
38-
[[= include_file('code_samples/back_office/image_editor/config/webpack.config.js', 6, 7) =]]//...
39-
[[= include_file('code_samples/back_office/image_editor/config/webpack.config.js', 50, 55) =]]
37+
``` js hl_lines="10 14"
38+
[[= include_file('code_samples/back_office/image_editor/config/webpack.config.js', 49, 63) =]]
4039
```
4140
At this point you should be able to see a new button in the Image Editor's UI.
4241

0 commit comments

Comments
 (0)