Skip to content

Commit 400deee

Browse files
Kasper Hansenjaviereguiluz
authored andcommitted
[Doc] Add resolve condition names to UX Svelte documentation
1 parent 71412bc commit 400deee

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

src/Svelte/doc/index.rst

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,22 @@ Next, install a package to help Svelte:
5151
That's it! Any files inside ``assets/svelte/controllers/`` can now be rendered as
5252
Svelte components.
5353

54+
If you are using Svelte 4, you will have to add ``browser``, ``import`` and ``svelte``
55+
to the ``conditionNames`` array. This is necessary as per `the Svelte 4 migration guide`_
56+
for bundlers such as webpack, to ensure that lifecycle callbacks are internally invoked.
57+
58+
To modify the ``conditionNames`` array, append the following changes to the bottom
59+
of your ``webpack.config.js`` file:
60+
61+
.. code-block:: javascript
62+
63+
// webpack.config.js
64+
65+
// module.exports = Encore.getWebpackConfig();
66+
const config = Encore.getWebpackConfig();
67+
config.resolve.conditionNames = ['browser', 'import', 'svelte'];
68+
module.exports = config;
69+
5470
Usage
5571
-----
5672

@@ -146,3 +162,4 @@ https://symfony.com/doc/current/contributing/code/bc.html
146162
.. _`Svelte`: https://svelte.dev/
147163
.. _`the Symfony UX initiative`: https://symfony.com/ux
148164
.. _StimulusBundle configured in your app: https://symfony.com/bundles/StimulusBundle/current/index.html
165+
.. _the Svelte 4 migration guide: https://svelte.dev/docs/v4-migration-guide#browser-conditions-for-bundlers

0 commit comments

Comments
 (0)