Skip to content

[Doc] Add resolve condition names to UX Svelte documentation #1689

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions src/Svelte/doc/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,22 @@ Next, install a package to help Svelte:
That's it! Any files inside ``assets/svelte/controllers/`` can now be rendered as
Svelte components.

If you are using Svelte 4, you will have to add ``browser``, ``import`` and ``svelte``
to the ``conditionNames`` array. This is necessary as per `the Svelte 4 migration guide`_
for bundlers such as webpack, to ensure that lifecycle callbacks are internally invoked.

To modify the ``conditionNames`` array, append the following changes to the bottom
of your ``webpack.config.js`` file:

.. code-block:: javascript

// webpack.config.js

// module.exports = Encore.getWebpackConfig();
const config = Encore.getWebpackConfig();
config.resolve.conditionNames = ['browser', 'import', 'svelte'];
module.exports = config;

Usage
-----

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