Skip to content

Multiple entrypoints, manifest.json, entrypoints.json and encore_entry_script_tags() #92

Closed
@plashenkov

Description

@plashenkov

Hi!

I am trying to use multiple Webpack configs in my webpack.config.json. Following this guide — https://symfony.com/doc/current/frontend/encore/advanced-config.html — I've specified all builds inside webpack_encore.yaml. And then I've tried to output my script(s) in my Twig template:

{{ encore_entry_script_tags('entry', null, 'build_name') }}

But I've got the following error:

An exception has been thrown during the rendering of a template ("Asset manifest file "/[path]/public/build/manifest.json" does not exist.").

Okay... but there is nothing about that neither in the docs nor in the webpack_encore.yaml.

After some digging I've found assets.yaml and that disabling assets.json_manifest_path solves this issue and everything renders.

But I am still not sure — I do everything correctly or not. Maybe I have to specify builds (which are named "packages") inside assets.yaml as well? And then:

{{ encore_entry_script_tags('entry', 'build_name', 'build_name') }}

But... I have to repeat the same parameter twice for some reason. And I have to specify my Webpack builds in several config files (under different keys).

It looks absolutely unintuitive. And there is a lack of information in the documentation about this.

P.S. I've found this: https://symfony.com/doc/current/frontend/encore/versioning.html

The first file - entrypoints.json - is used by the encore_entry_script_tags() and encore_entry_link_tags() Twig helpers.

The manifest.json file is only needed to get the versioned filename of other files [...] Be sure to wrap each path in the Twig asset() function like normal

I.e. entrypoints.json for encore_entry_script_tags(), and manifest.json for asset()? But I still do not understand why encore_entry_script_tags() needs both parameters. If we can disable assets.json_manifest_path in assets.yaml and everything seems to work without it why does encore_entry_script_tags() depend on both parameters? Why can't we make encore_entry_script_tags() and asset() dependent on the same unified parameter?

P.P.S. Honestly, in ideal world it would be great to specify builds only inside webpack.config.json and then just use them in encore_entry_script_tags() without adding them manually in several configs.


Summarizing:

  1. Using multiple builds looks confusing now.
  2. Following documentation doesn't give us working result.
  3. Lack of info why everything is as it is.

Thank you! :)

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions