Skip to content

Commit 91d8c76

Browse files
committed
minor #11593 fix encore multiple configuration build paths (gseidel)
This PR was submitted for the 4.2 branch but it was merged into the 3.4 branch instead (closes #11593). Discussion ---------- fix encore multiple configuration build paths This PR fix two things: - `%kernel.public_dir%` does not exists and `%kernel.project_dir%/public` is the correct path. - As mentioned here symfony/webpack-encore#477, the multiple config will overwrite the `entrypoint.js`. The solution is to use two build directories, but this needs two different paths in the `webpack.config.js`. Now someone can just copy&paste the code lines and it should work. Commits ------- 81f9491 fix encore multiple configuration build paths
2 parents e2c3021 + 81f9491 commit 91d8c76

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

frontend/encore/advanced-config.rst

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -63,8 +63,8 @@ state of the current configuration to build a new one:
6363
6464
// define the first configuration
6565
Encore
66-
.setOutputPath('web/build/')
67-
.setPublicPath('/build')
66+
.setOutputPath('web/build/first_build/')
67+
.setPublicPath('/build/first_build')
6868
.addEntry('app', './assets/js/app.js')
6969
.addStyleEntry('global', './assets/css/global.scss')
7070
.enableSassLoader()
@@ -83,8 +83,8 @@ state of the current configuration to build a new one:
8383
8484
// define the second configuration
8585
Encore
86-
.setOutputPath('web/build/')
87-
.setPublicPath('/build')
86+
.setOutputPath('web/build/second_build/')
87+
.setPublicPath('/build/second_build')
8888
.addEntry('mobile', './assets/js/mobile.js')
8989
.addStyleEntry('mobile', './assets/css/mobile.less')
9090
.enableLessLoader()
@@ -113,10 +113,10 @@ Next, define the output directories of each build:
113113
114114
# app/config/config.yml
115115
webpack_encore:
116-
output_path: '%kernel.public_dir%/web/default_build'
116+
output_path: '%kernel.project_dir%/web/default_build'
117117
builds:
118-
firstConfig: '%kernel.public_dir%/web/first_build'
119-
secondConfig: '%kernel.public_dir%/web/second_build'
118+
firstConfig: '%kernel.project_dir%/web/first_build'
119+
secondConfig: '%kernel.project_dir%/web/second_build'
120120
121121
Finally, use the third optional parameter of the ``encore_entry_*_tags()``
122122
functions to specify which build to use:

0 commit comments

Comments
 (0)