heimrichhannot / contao-encore-bundle
This bundle brings deep integration for symfony encore into contao. On the one hand, your can prepare your bundles to define own webpack entries, which added with just one command to your webpack entries. On the other hand, this bundle allows you to add encore entries only on the pages you need the
Package info
github.com/heimrichhannot/contao-encore-bundle
Type:contao-bundle
pkg:composer/heimrichhannot/contao-encore-bundle
Requires
- php: ^8.2
- composer-runtime-api: ^2.0
- ext-json: *
- contao/core-bundle: ^5.3
- heimrichhannot/contao-encore-contracts: ^1.5
- heimrichhannot/contao-multi-column-editor-bundle: ^2.0
- heimrichhannot/contao-utils-bundle: ^3.0
- symfony/cache: ^6.4 || ^7.0
- symfony/config: ^6.4 || ^7.0
- symfony/console: ^6.4 || ^7.0
- symfony/dependency-injection: ^6.4 || ^7.0
- symfony/deprecation-contracts: ^3.0
- symfony/filesystem: ^6.4 || ^7.0
- symfony/http-foundation: ^6.4 || ^7.0
- symfony/http-kernel: ^6.4 || ^7.0
- symfony/translation: ^6.4 || ^7.0
- symfony/translation-contracts: ^3.0
- symfony/webpack-encore-bundle: ^2.0
- twig/twig: ^3.0
Requires (Dev)
- contao/contao-rector: dev-main
- contao/manager-plugin: ^2.13
- contao/test-case: ^5.3
- heimrichhannot/contao-test-utilities-bundle: ^0.1.4
- php-coveralls/php-coveralls: ^2.0
- phpstan/phpstan: ^1.12 || ^2.0
- phpstan/phpstan-symfony: ^1.4 || ^2.0
- phpunit/phpunit: ^9.6
- rector/rector: ^1.2 || ^2.0
- symfony/phpunit-bridge: ^6.4 || ^7.0
- symplify/easy-coding-standard: ^12.5
Suggests
None
Provides
None
Conflicts
None
Replaces
None
- v2.x-dev
- 2.4.0
- 2.3.1
- 2.3.0
- 2.2.2
- 2.2.1
- 2.2.0
- 2.1.1
- 2.1.0
- 2.0.0
- 2.0.0-beta3
- 2.0.0-beta2
- 2.0.0-beta
- v1.x-dev
- 1.20.2
- 1.20.1
- 1.20.0
- 1.19.0
- 1.18.1
- 1.18.0
- 1.17.4
- 1.17.3
- 1.17.2
- 1.17.1
- 1.17.0
- 1.16.1
- 1.16.0
- 1.15.1
- 1.15.0
- 1.14.0
- 1.13.0
- 1.12.1
- 1.12.0
- 1.11.2
- 1.11.1
- 1.11.0
- 1.10.0
- 1.9.2
- 1.9.1
- 1.9.0
- 1.8.5
- 1.8.4
- 1.8.3
- 1.8.2
- 1.8.1
- 1.8.0
- 1.7.0
- 1.6.3
- 1.6.2
- 1.6.1
- 1.6.0
- 1.5.3
- 1.5.2
- 1.5.1
- 1.5.0
- 1.4.1
- 1.4.0
- 1.3.2
- 1.3.1
- 1.3.0
- 1.2.2
- 1.2.1
- 1.2.0
- 1.1.4
- 1.1.3
- 1.1.2
- 1.1.1
- 1.1.0
- 1.0.3
- 1.0.2
- 1.0.1
- 1.0.0
- 0.8.3
- 0.8.2
- 0.8.1
- 0.8.0
- 0.7.0
- 0.6.0
- 0.5.0
- 0.4.4
- 0.4.3
- 0.4.2
- 0.4.1
- 0.4.0
- 0.3.0
- 0.2.0
- 0.1.2
- 0.1.1
- 0.1.0
This package is auto-updated.
Last update: 2026-11-17 13:13:38 UTC
README
Use the power and simplicity of symfony webpack encore in contao. This bundle let you decide on theme, layout and page level, which encore entries should be loaded. If you want more, you can prepare your bundles define their own encore entries, so never need to manually add or remove encore entries again.
Features
- use symfony encore (symfony/webpack-encore and symfony/webpack-encore-bundle) to enhance your contao assets workflow
- conditionally load your assets only if necessary (entrypoints can be activated in the backend in layout and page setting or added from your bundle code (e.g. in a frontend module))
- prepare your bundles to add encore entries when install them and strip assets from the contao global asset arrays
Setup
Prerequisites
- Read the Encore Documentation in order to install Encore and understand the core concepts of Webpack and Symfony Encore.
Prepare your project and bundle
Setup your project for encore bundle:
➡️ Bundle setup
Run Encore
-
Run encore prepare command
php vendor/bin/contao-console huh:encore:prepare -
If (yarn) dependencies have changed, run yan install
yarn install -
Run encore to generate the assets
yarn encore dev -
Activate encore entries in the contao backend (if not added from code)
Usage
Activate encore entries
- In the Contao backend, edit a theme and check "Activate Webpack Encore".
- Select the entries that all layouts of this theme should inherit.
You can add additional entries or disable inherited entries layout or page level. It is also possible to disable encore completely for a specific layout.
Entries are resolved in this order: theme → layout → parent pages → current page. The more specific setting wins. If Encore is enabled explicitly in a layout, it also receives the theme's entries even when the theme's activation checkbox is unchecked.
Prepare command
php vendor/bin/contao-console huh:encore:prepare
The prepare command must be executed after every change to the encore entries configuration, e.g. after a composer update or changes to that configurations in your own code.
The command collect encore entries from all bundle and creates a file called encore.bundles.js in your project root.
This file contains entries for all contao encore compatible bundles that are added by calling encoreBundles.addEntries(); in your webpack.config.js.
It also collects the dependencies from the package.json files of bundles have EncoreExtensions registered and adds them to the project dependencies.
Description:
Does the necessary preparation for contao encore bundle. Needs to be called after changes to bundle encore entries.
Usage:
huh:encore:prepare [options]
encore:prepare
Options:
--skip-entries[=SKIP-ENTRIES] Add a comma separated list of entries to skip their generation. [default: false]
Run encore
Run encore to generate/compile your assets.
yarn encore dev
yarn encore dev --watch
yarn encore prod
Documentation
Project setup - Prepare your contao project for use with encore and encore bundle
Bundle setup - Add encore bundle support to your bundle
Setup Javascript - Help about setting up your encore entries