PHPackages                             maxencebeno/webpack-encore-bundle - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Utility &amp; Helpers](/categories/utility)
4. /
5. maxencebeno/webpack-encore-bundle

ActiveSymfony-bundle[Utility &amp; Helpers](/categories/utility)

maxencebeno/webpack-encore-bundle
=================================

Integration with your Symfony app &amp; Webpack Encore!

v1.7.4(6y ago)070MITPHPPHP ^7.1.3

Since Nov 3Pushed 6y agoCompare

[ Source](https://github.com/maxencebeno/webpack-encore-bundle)[ Packagist](https://packagist.org/packages/maxencebeno/webpack-encore-bundle)[ RSS](/packages/maxencebeno-webpack-encore-bundle/feed)WikiDiscussions master Synced today

READMEChangelog (1)Dependencies (9)Versions (20)Used By (0)

WebpackEncoreBundle: Symfony integration with Webpack Encore!
=============================================================

[](#webpackencorebundle-symfony-integration-with-webpack-encore)

This bundle allows you to use the `splitEntryChunks()` feature from [Webpack Encore](https://symfony.com/doc/current/frontend.html)by reading an `entrypoints.json` file and helping you render all of the dynamic `script` and `link` tags needed.

Install the bundle with:

```
composer require symfony/webpack-encore-bundle

```

Configuration
-------------

[](#configuration)

If you're using Symfony Flex, you're done! The recipe will pre-configure everything you need in the `config/packages/webpack_encore.yaml`file:

```
# config/packages/webpack_encore.yaml
webpack_encore:
    # The path where Encore is building the assets - i.e. Encore.setOutputPath()
    output_path: '%kernel.project_dir%/public/build'
    # If multiple builds are defined (as shown below), you can disable the default build:
    # output_path: false

    # if using Encore.enableIntegrityHashes() and need the crossorigin attribute (default: false, or use 'anonymous' or 'use-credentials')
    # crossorigin: 'anonymous'

    # preload all rendered script and link tags automatically via the http2 Link header
    # preload: true

    # Throw an exception if the entrypoints.json file is missing or an entry is missing from the data
    # strict_mode: false

    # if you have multiple builds:
    # builds:
        # pass "frontend" as the 3rg arg to the Twig functions
        # {{ encore_entry_script_tags('entry1', null, 'frontend') }}

        # frontend: '%kernel.project_dir%/public/frontend/build'

    # Cache the entrypoints.json (rebuild Symfony's cache when entrypoints.json changes)
    # Available in version 1.2
    # Put in config/packages/prod/webpack_encore.yaml
    # cache: true
```

Usage
-----

[](#usage)

The "Split Chunks" functionality in Webpack Encore is enabled by default with the recipe if you install this bundle using Symfony Flex. Otherwise, enable it manually:

```
// webpack.config.js
// ...
    .setOutputPath('public/build/')
    .setPublicPath('/build')
    .setManifestKeyPrefix('build/')

    .addEntry('entry1', './assets/some_file.js')

+   .splitEntryChunks()
// ...
```

When you enable `splitEntryChunks()`, instead of just needing 1 script tag for `entry1.js` and 1 link tag for `entry1.css`, you may now need *multiple*script and link tags. This is because Webpack ["splits" your files](https://webpack.js.org/plugins/split-chunks-plugin/)into smaller pieces for greater optimization.

To help with this, Encore writes an `entrypoints.json` file that contains all of the files needed for each "entry".

For example, to render all of the `script` and `link` tags for a specific "entry" (e.g. `entry1`), you can:

```
{# any template or base layout where you need to include a JavaScript entry #}

{% block javascripts %}
    {{ parent() }}

    {{ encore_entry_script_tags('entry1') }}
{% endblock %}

{% block stylesheets %}
    {{ parent() }}

    {{ encore_entry_link_tags('entry1') }}
{% endblock %}
```

Assuming that `entry1` required two files to be included - `build/vendor~entry1~entry2.js`and `build/entry1.js`, then `encore_entry_script_tags()` is equivalent to:

```

```

If you want more control, you can use the `encore_entry_js_files()` and `encore_entry_css_files()` methods to get the list of files needed, then loop and create the `script` and `link` tags manually.

Rendering Multiple Times in a Request (e.g. to Generate a PDF)
--------------------------------------------------------------

[](#rendering-multiple-times-in-a-request-eg-to-generate-a-pdf)

When you render your script or link tags, the bundle is smart enough not to repeat the same JavaScript or CSS file within the same request. This prevents you from having duplicate `` or `` tags if you render multiple entries that both rely on the same file.

In some cases, however, you may want to render the script &amp; link tags for the same entry multiple times in a request. For example, if you render multiple Twig templates to create multiple PDF files during a single request.

In that case, before each render, you'll need to "reset" the internal cache so that the bundle re-renders CSS or JS files that it previously rendered. For example, in a controller:

```
// src/Controller/SomeController.php

use Symfony\WebpackEncoreBundle\Asset\EntrypointLookupInterface;

class SomeController
{
    public function index(EntrypointLookupInterface $entrypointLookup)
    {
        $entrypointLookup->reset();
        // render a template

        $entrypointLookup->reset();
        // render another template

        // ...
    }
}
```

If you have multiple builds, you can also autowire `Symfony\WebpackEncoreBundle\Asset\EntrypointLookupCollectionInterface`and use it to get the `EntrypointLookupInterface` object for any build.

###  Health Score

30

—

LowBetter than 62% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity8

Limited adoption so far

Community18

Small or concentrated contributor base

Maturity66

Established project with proven stability

 Bus Factor2

2 contributors hold 50%+ of commits

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~39 days

Recently: every ~61 days

Total

16

Last Release

2201d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/7147212?v=4)[Maxence Beno](/maintainers/maxencebeno)[@maxencebeno](https://github.com/maxencebeno)

---

Top Contributors

[![weaverryan](https://avatars.githubusercontent.com/u/121003?v=4)](https://github.com/weaverryan "weaverryan (57 commits)")[![PhilETaylor](https://avatars.githubusercontent.com/u/400092?v=4)](https://github.com/PhilETaylor "PhilETaylor (17 commits)")[![shulard](https://avatars.githubusercontent.com/u/482993?v=4)](https://github.com/shulard "shulard (7 commits)")[![codayblue](https://avatars.githubusercontent.com/u/7281660?v=4)](https://github.com/codayblue "codayblue (6 commits)")[![nicolas-grekas](https://avatars.githubusercontent.com/u/243674?v=4)](https://github.com/nicolas-grekas "nicolas-grekas (4 commits)")[![Lyrkan](https://avatars.githubusercontent.com/u/850046?v=4)](https://github.com/Lyrkan "Lyrkan (2 commits)")[![maxencebeno](https://avatars.githubusercontent.com/u/7147212?v=4)](https://github.com/maxencebeno "maxencebeno (2 commits)")[![bocharsky-bw](https://avatars.githubusercontent.com/u/3317635?v=4)](https://github.com/bocharsky-bw "bocharsky-bw (2 commits)")[![emodric](https://avatars.githubusercontent.com/u/362286?v=4)](https://github.com/emodric "emodric (2 commits)")[![fabpot](https://avatars.githubusercontent.com/u/47313?v=4)](https://github.com/fabpot "fabpot (2 commits)")[![fionera](https://avatars.githubusercontent.com/u/5741401?v=4)](https://github.com/fionera "fionera (2 commits)")[![keradus](https://avatars.githubusercontent.com/u/2716794?v=4)](https://github.com/keradus "keradus (2 commits)")[![Nyholm](https://avatars.githubusercontent.com/u/1275206?v=4)](https://github.com/Nyholm "Nyholm (1 commits)")[![MolloKhan](https://avatars.githubusercontent.com/u/3451985?v=4)](https://github.com/MolloKhan "MolloKhan (1 commits)")[![Seb33300](https://avatars.githubusercontent.com/u/915273?v=4)](https://github.com/Seb33300 "Seb33300 (1 commits)")[![karser](https://avatars.githubusercontent.com/u/1675033?v=4)](https://github.com/karser "karser (1 commits)")[![smoelker](https://avatars.githubusercontent.com/u/5102879?v=4)](https://github.com/smoelker "smoelker (1 commits)")[![steven-pribilinskiy](https://avatars.githubusercontent.com/u/3078595?v=4)](https://github.com/steven-pribilinskiy "steven-pribilinskiy (1 commits)")[![tbmatuka](https://avatars.githubusercontent.com/u/1024167?v=4)](https://github.com/tbmatuka "tbmatuka (1 commits)")[![wbrinkman](https://avatars.githubusercontent.com/u/1305257?v=4)](https://github.com/wbrinkman "wbrinkman (1 commits)")

### Embed Badge

![Health badge](/badges/maxencebeno-webpack-encore-bundle/health.svg)

```
[![Health](https://phpackages.com/badges/maxencebeno-webpack-encore-bundle/health.svg)](https://phpackages.com/packages/maxencebeno-webpack-encore-bundle)
```

###  Alternatives

[easycorp/easyadmin-bundle

Admin generator for Symfony applications

4.3k17.9M388](/packages/easycorp-easyadmin-bundle)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
