PHPackages                             68publishers/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. 68publishers/webpack-encore-bundle

ActiveLibrary

68publishers/webpack-encore-bundle
==================================

Nette integration with Webpack Encore! https://symfony.com/webpack-encore

v3.3.0(1y ago)729.7k↓46%1MITPHPPHP ^8.3CI passing

Since May 31Pushed 1y ago3 watchersCompare

[ Source](https://github.com/68publishers/webpack-encore-bundle)[ Packagist](https://packagist.org/packages/68publishers/webpack-encore-bundle)[ RSS](/packages/68publishers-webpack-encore-bundle/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (8)Dependencies (21)Versions (10)Used By (0)

Nette integration with Webpack Encore
=====================================

[](#nette-integration-with-webpack-encore)

This package 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.

Inspired by [symfony/webpack-encore-bundle](https://github.com/symfony/webpack-encore-bundle)

[![Checks](https://camo.githubusercontent.com/6f5952d1b90a958ab45ba290617241ec70e4bf523576fc0a64befaa6a15f1461/68747470733a2f2f62616467656e2e6e65742f6769746875622f636865636b732f36387075626c6973686572732f7765627061636b2d656e636f72652d62756e646c652f6d6173746572)](https://github.com/68publishers/webpack-encore-bundle/actions)[![Coverage Status](https://camo.githubusercontent.com/803096d1380cf1a93e6cee0d4f530571d7c22652970e1a95ca4bf8a7906795c1/68747470733a2f2f636f766572616c6c732e696f2f7265706f732f6769746875622f36387075626c6973686572732f7765627061636b2d656e636f72652d62756e646c652f62616467652e7376673f6272616e63683d6d6173746572)](https://coveralls.io/github/68publishers/webpack-encore-bundle?branch=master)[![Total Downloads](https://camo.githubusercontent.com/38092ec4cb4a69816f63f21fc4b506a32a4e0181ef9e76a6c9bbfa743cd539d9/68747470733a2f2f62616467656e2e6e65742f7061636b61676973742f64742f36387075626c6973686572732f7765627061636b2d656e636f72652d62756e646c65)](https://packagist.org/packages/68publishers/webpack-encore-bundle)[![Latest Version](https://camo.githubusercontent.com/89acf8aa5b655b08daa80137eb2ad36a3713fc83525ca46f4383756d3c0bae47/68747470733a2f2f62616467656e2e6e65742f7061636b61676973742f762f36387075626c6973686572732f7765627061636b2d656e636f72652d62756e646c65)](https://packagist.org/packages/68publishers/webpack-encore-bundle)[![PHP Version](https://camo.githubusercontent.com/be93a7e89b24bd485bab64503e08fba4bc48c34f1035f2ebce8753a8809ffce0/68747470733a2f2f62616467656e2e6e65742f7061636b61676973742f7068702f36387075626c6973686572732f7765627061636b2d656e636f72652d62756e646c65)](https://packagist.org/packages/68publishers/webpack-encore-bundle)

Installation
------------

[](#installation)

The best way to install 68publishers/webpack-encore-bundle is using Composer:

```
$ composer require 68publishers/webpack-encore-bundle
```

the package requires integration with [symfony/asset](https://github.com/symfony/asset). We recommend using of our package [68publishers/asset](https://github.com/68publishers/asset), but you can use your own integration.

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

[](#configuration)

First, register a compiler extension into DIC:

```
extensions:
	encore: SixtyEightPublishers\WebpackEncoreBundle\Bridge\Nette\DI\WebpackEncoreBundleExtension
```

### Minimal Configuration

[](#minimal-configuration)

```
encore:
	# The path where Encore is building the assets - i.e. Encore.setOutputPath()
	output_path: %wwwDir%/public/build
```

You must also set the manifest path for the Asset component. If you are using [68publishers/asset](https://github.com/68publishers/asset), the configuration might look something like this:

```
asset:
	json_manifest_path: %wwwDir%/public/build/manifest.json
```

### Multiple builds

[](#multiple-builds)

```
encore:
	output_path: null # or just omit this option
	builds:
		frontend: %wwwDir%/public/frontend/build
		another: %wwwDir%/public/another/build
```

### Default attributes

[](#default-attributes)

```
encore:
	# if using Encore.enableIntegrityHashes() and need the crossorigin attribute. Allowed values are NULL, 'anonymous' or 'use-credentials'. Default is NULL.
	crossorigin: anonymous

	# Set attributes that will be rendered on all script tags
	script_attributes:
		defer: yes
		referrerpolicy: origin

	# Set attributes that will be rendered on all link tags
	link_attributes:
		referrerpolicy: origin
```

### HTTP Preload

[](#http-preload)

All scripts and styles will be preloaded via [HTTP2 header `Link`](https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Link) if the option is enabled.

```
encore:
	preload: yes
```

### Entrypoints.json cache

[](#entrypointsjson-cache)

The parsed content of the `entrypoints.json` file can be cached for faster loading. It is necessary to have the application integrated with [`symfony/console`](https://github.com/symfony/console) for this feature to work, as the cache must be created manually using the console command.

```
encore:
	cache: yes # you can use %debugMode%
```

To generate the cache, run the following command:

```
$ bin/console encore:warmup-cache
```

The cache file will be generated as `%wwwDir%//cache/webpack_encore.cache.php`.

❗ Cache must be regenerated when the entrypoints.json changes. Use the option in a production environment only and run the command within an application build.

### Strict mode

[](#strict-mode)

By default, if we want to render tags for an entry that is not defined in the `entrypoints.json`, the application throws an `EntryPointNotFoundException` exception. You can disable this behaviour:

```
encore:
	strict_mode: no
```

Usage in Latte templates
------------------------

[](#usage-in-latte-templates)

Script and Links tags should be rendered with macros `encore_js` and `encore_css`:

```
{*
    {encore_js string $entryName, ?string $packageName, ?string $entrypointName, array $extraAttributes = []}
    {encore_css string $entryName, ?string $packageName, ?string $entrypointName, array $extraAttributes = []}
*}

{block js}
    {include parent}

    {encore_js 'entry1'}
    {* if you are using multiple builds *}
    {encore_js, 'entry1', null, 'frontend'}
    {* if you want to pass extra attributes *}
    {encore_js 'entry1' null, null, ['async' => true]}
{/block}

{block stylesheets}
    {include parent}

    {encore_css 'entry1'}
    {* if you are using multiple builds *}
    {encore_css, 'entry1', null, 'frontend'}
    {* if you want to pass extra attributes *}
    {encore_css 'entry1' null, null, ['hreflang' => 'en']}
{/block}
```

If for some reason you need manual access to individual file names, you can use the following Latte functions:

```
{*
    {encore_js_files(string $entryName, ?string $entrypointName): array}
    {encore_css_files(string $entryName, ?string $entrypointName): array}
    {encore_entry_exists(string $entryName, ?string $entrypointName): bool}
*}

{foreach encore_js_files('entry1') as $file}
    {var $asset = asset($file)}
{/foreach}

{foreach encore_css_files('entry1') as $file}
    {var $asset = asset($file)}
{/foreach}

{* Render tags for entry `entry2` only if the entry exists (prevents an exception throwing in a strict mode) *}
{if encore_entry_exists('entry2')}
    {encore_js 'entry2'}
{/if}
```

Events
------

[](#events)

If your application is integrated with [symfony/event-dispatcher](https://github.com/symfony/event-dispatcher), you can handle the event `RenderAssetTagEvent` that is called when a script or link tag is generated.

```
namespace App\EventSubscriber;

use Symfony\Component\EventDispatcher\EventSubscriberInterface;
use SixtyEightPublishers\WebpackEncoreBundle\Event\RenderAssetTagEvent;

final class ScriptNonceSubscriber implements EventSubscriberInterface
{
    public static function getSubscribedEvents()
    {
        return [
            RenderAssetTagEvent::class => 'onRenderAssetTag',
        ];
    }

    public function onRenderAssetTag(RenderAssetTagEvent $event): void
    {
        if ($event->isScriptTag()) {
            $event->setAttribute('nonce', 'lookup nonce');
        }
    }
}
```

Contributing
------------

[](#contributing)

Before opening a pull request, please check your changes using the following commands

```
$ make init # to pull and start all docker images

$ make cs.check
$ make stan
$ make tests.all
```

###  Health Score

47

—

FairBetter than 94% of packages

Maintenance43

Moderate activity, may be stable

Popularity33

Limited adoption so far

Community14

Small or concentrated contributor base

Maturity80

Battle-tested with a long release history

 Bus Factor1

Top contributor holds 84.8% of commits — single point of failure

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 ~299 days

Recently: every ~204 days

Total

8

Last Release

448d ago

Major Versions

v1.1 → v2.02020-10-27

v2.0 → v3.0.02022-11-29

PHP version history (4 changes)v1.0PHP ~7.1

v1.1PHP ^7.2

v3.0.0PHP ^7.4 || ^8.0

v3.2.0PHP ^8.3

### Community

Maintainers

![](https://www.gravatar.com/avatar/609005caba54757716c3c037c381376ab298714003da87c9e20aa8c501c97df8?d=identicon)[Jelen](/maintainers/Jelen)

---

Top Contributors

[![tg666](https://avatars.githubusercontent.com/u/24430186?v=4)](https://github.com/tg666 "tg666 (28 commits)")[![jelen07](https://avatars.githubusercontent.com/u/2346295?v=4)](https://github.com/jelen07 "jelen07 (3 commits)")[![krkabol](https://avatars.githubusercontent.com/u/1556307?v=4)](https://github.com/krkabol "krkabol (1 commits)")[![scrutinizer-auto-fixer](https://avatars.githubusercontent.com/u/6253494?v=4)](https://github.com/scrutinizer-auto-fixer "scrutinizer-auto-fixer (1 commits)")

---

Tags

encorenettesymfonywebpackwebpack-encorenettewebpack68publisherswebpack-encorewebpack-encore-bundle

###  Code Quality

Static AnalysisPHPStan

Code StylePHP CS Fixer

Type Coverage Yes

### Embed Badge

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

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

###  Alternatives

[contributte/translation

Symfony/Translation integration for Nette Framework.

771.8M37](/packages/contributte-translation)[kdyby/translation

Integration of Symfony/Translation into Nette Framework

921.2M24](/packages/kdyby-translation)[contributte/webpack

Webpack integration for Nette Framework.

471.0M1](/packages/contributte-webpack)[contributte/image-storage

Image storage for Nette framework

28749.3k1](/packages/contributte-image-storage)

PHPackages © 2026

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