Skip to content

Commit 078e32a

Browse files
committed
minor #15044 [Encore] Deploying to a CDN subdirectory (t-richard)
This PR was merged into the 4.4 branch. Discussion ---------- [Encore] Deploying to a CDN subdirectory <!-- If your pull request fixes a BUG, use the oldest maintained branch that contains the bug (see https://symfony.com/releases for the list of maintained branches). If your pull request documents a NEW FEATURE, use the same Symfony branch where the feature was introduced (and `5.x` for features of unreleased versions). --> When deploying to a CDN, you might want to deploy your whole public directory to also include bundles assets for example. This would result in the CDN containing two folders `bundles` and `build` when using Encore. This may also be the case if using a shared CDN for multiple applications where each project lives in a given folder. This PR tries to document this and it seems the only solution is to add the path of the subdirectory at the end of the URL. It's even showcased in the code comments [here](https://github.com/symfony/webpack-encore/blob/main/index.js#L84). Commits ------- e3328a4 [Encore] Deploying to a CDN subdirectory
2 parents 69c6ef7 + e3328a4 commit 078e32a

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

frontend/encore/cdn.rst

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,10 @@ pages also use the CDN. Fortunately, the
3939
:ref:`entrypoints.json <encore-entrypointsjson-simple-description>` paths are updated
4040
to include the full URL to the CDN.
4141

42+
When deploying to a subdirectory of your CDN, you must add the path at the end of your URL -
43+
e.g. ``Encore.setPublicPath('https://my-cool-app.com.global.prod.fastly.net/awesome-website')``
44+
will generate assets URLs like ``https://my-cool-app.com.global.prod.fastly.net/awesome-website/dashboard.js``
45+
4246
If you are using ``Encore.enableIntegrityHashes()`` and your CDN and your domain
4347
are not the `same-origin`_, you may need to set the ``crossorigin`` option in
4448
your webpack_encore.yaml configuration to ``anonymous`` or ``use-credentials``

0 commit comments

Comments
 (0)