Skip to content

[Bug]: Static pages are missing Webpack-Encore includes #16220

@astehlik

Description

@astehlik

Pimcore version

11.1.0

Steps to reproduce

  1. Set up a Pimcore Project with Webpack Encore Bundle Integration
  2. Pepare the pages
    • Enable static page generation for the root page with a lifetime of 1 minute
    • Create and publish another page and use the same setting
  3. Wait for the maintenance job (\Pimcore\Maintenance\Tasks\StaticPagesGenerationTask) to refresh the pages or call pimcore:maintenance manually. Wait at least a minute to make sure both pages are refreshed at the same time.

Actual Behavior

The style and JS includes are only present in one page. In all other pages they are missing (the background is no longer grey).

The reason for this problem can be found in the Encore logic:

  • The \Symfony\WebpackEncoreBundle\Asset\EntrypointLookup will only return the files that should be included once until the $returnedFiles property is reset.
  • This is normally done by the \Symfony\WebpackEncoreBundle\EventListener\ResetAssetsEventListener at the kernel.finish_request event
  • The event is triggered during document generation but the reset is not executed because the method \Symfony\Component\HttpKernel\Fragment\InlineFragmentRenderer::render() uses a sub-request. In that case the reset is skipped.

Expected Behavior

The styles are included in all pages.

The problem can be solved by using an event listener that manually resets the entrypoint lookup on the pimcore.document.renderer.post_render.

I'm not sure if this is something that should be provided by the Pimcore core of if it only should be documented somewhere.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions