Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

[UX] Expose entrypoint#21292

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Open
Jibbarth wants to merge1 commit intosymfony:6.4
base:6.4
Choose a base branch
Loading
fromJibbarth:assets-entrypoint
Open
Changes fromall 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
108 changes: 108 additions & 0 deletionsfrontend/create_ux_bundle.rst
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -205,3 +205,111 @@
return is_file($bundlesMetadata['FrameworkBundle']['path'] . '/Resources/config/asset_mapper.php');
}
}

Expose an entrypoint
--------------------

An entrypoint is a file that need to be always loaded, to usually start your application.

It's usefull if your bundle have dedicated views, for example :

* /admin
* /translations
* /dashboard


On a Standard symfony app, it's the ``app`` loaded by webpack encore or importmap.

With Webpack Encore
~~~~~~~~~~~~~~~~~~~

In the ``package.json`` file, define your entrypoint inside the ``symfony.entrypoints`` key:

.. code-block:: json

{
"name": "@acme/feature",
"symfony": {
"entrypoints": {
"@acme/feature/entrypoint": "../node_modules/@acme/feature/entrypoint.js"
}
}
}


The key is the entry that will be called in your templates, and the value is the path that webpack will use to load the file.

.. note::

The path must be relative to ``assets`` folder of the symfony application.


That value will be copied inside the ``assets/controllers.json`` file after the bundle installation.

In your templates, make sure to load that entry :

.. code-block:: html+twig

Check failure on line 251 in frontend/create_ux_bundle.rst

View workflow job for this annotation

GitHub Actions/ Lint (DOCtor-RST)

Please use "twig" instead of "html+twig"

{# templates/my-bundle-base.html.twig #}
...
{% block stylesheets %}
{{ encore_entry_link_tags('@acme/feature/entrypoint') }}
{% endblock %}

{% block javascripts %}
{{ encore_entry_script_tags('@acme/feature/entrypoint') }}
{% endblock %}


.. warning::

Is it mandatory to have stimulus-bundle and the ``.enableStimulusBridge('./assets/controllers.json')`` added to the webpack.config.js to be able to use the entrypoints.


With Asset Mapper
~~~~~~~~~~~~~~~~~

In the ``package.json`` file, define your entrypoint inside the ``symfony.importmap`` key:

.. code-block:: json

{
"name": "@acme/feature",
"symfony": {
"importmap": {
"@acme/feature/entrypoint": "entrypoint:%PACKAGE%/entrypoint.js"
}
}
}

.. versionadded:: 2.7.0

Check failure on line 285 in frontend/create_ux_bundle.rst

View workflow job for this annotation

GitHub Actions/ Lint (DOCtor-RST)

Please only provide ".. versionadded::" if the version is greater/equal "6.0"

Check failure on line 285 in frontend/create_ux_bundle.rst

View workflow job for this annotation

GitHub Actions/ Lint (DOCtor-RST)

You are not allowed to use version "2.7.0". Only major version "6" is allowed.

The ``entrypoint`` keyword support was introduced in Symfony Flex 2.7.0


After installation, the entry will be added to the ``importmap.php``:

.. code-block:: php

Check failure on line 292 in frontend/create_ux_bundle.rst

View workflow job for this annotation

GitHub Actions/ Lint (DOCtor-RST)

Please do not use ".. code-block:: php", use "::" instead.

// importmap.php
return [
'app' => [
'path' => './assets/app.js',
'entrypoint' => true,
],
// ...
'@acme/feature/entrypoint' => [
'path' => './vendor/acme/feature-bundle/assets/entrypoint.js',
'entrypoint' => true,
],
];

In your templates, make sure to load that entry :

.. code-block:: html+twig

Check failure on line 309 in frontend/create_ux_bundle.rst

View workflow job for this annotation

GitHub Actions/ Lint (DOCtor-RST)

Please use "twig" instead of "html+twig"

{# templates/my-bundle-base.html.twig #}
...
{% block javascripts %}
{% block importmap %}{{ importmap('@acme/feature/entrypoint') }}{% endblock %}

Check failure on line 314 in frontend/create_ux_bundle.rst

View workflow job for this annotation

GitHub Actions/ Code Blocks

[Twig] Unknown "importmap" function.
{% endblock %}
Loading

[8]ページ先頭

©2009-2025 Movatter.jp