@@ -40,5 +40,48 @@ But be careful not to accidentally override any config from Encore:
4040 // BAD - this replaces any extensions added by Encore
4141 // config.resolve.extensions = ['json'];
4242
43+ Defining Multiple Webpack Configurations
44+ ----------------------------------------
45+
46+ Webpack supports passing an `array of configurations `_, which are processed in
47+ parallel. Webpack Encore includes a ``reset() `` object allowing to reset the
48+ state of the current configuration to build a new one:
49+
50+ .. code-block :: javascript
51+
52+ // define the first configuration
53+ Encore
54+ .setOutputPath (' web/build/' )
55+ .setPublicPath (' /build' )
56+ .addEntry (' app' , ' ./assets/js/main.js' )
57+ .addStyleEntry (' global' , ' ./assets/css/global.scss' )
58+ .enableSassLoader ()
59+ .autoProvidejQuery ()
60+ .enableSourceMaps (! Encore .isProduction ())
61+ ;
62+
63+ // build the first configuration
64+ const firstConfig = Encore .getWebpackConfig ();
65+
66+ // reset Encore to build the second config
67+ Encore .reset ();
68+
69+ // define the second configuration
70+ Encore
71+ .setOutputPath (' web/build/' )
72+ .setPublicPath (' /build' )
73+ .addEntry (' mobile' , ' ./assets/js/mobile.js' )
74+ .addStyleEntry (' mobile' , ' ./assets/css/mobile.less' )
75+ .enableLessLoader ()
76+ .enableSourceMaps (! Encore .isProduction ())
77+ ;
78+
79+ // build the second configuration
80+ const secondConfig = Encore .getWebpackConfig ();
81+
82+ // export the final configuration as an array of multiple configurations
83+ module .exports = [firstConfig, secondConfig];
84+
4385 .. _`configuration options` : https://webpack.js.org/configuration/
4486.. _`Webpack's watchOptions` : https://webpack.js.org/configuration/watch/#watchoptions
87+ .. _`array of configurations` : https://github.com/webpack/docs/wiki/configuration#multiple-configurations
0 commit comments