1.0.3 2022-09-17 17:42 UTC

This package is auto-updated.

Last update: 2024-06-18 02:10:46 UTC


Contao-Encore bridge

This is an extension for Contao CMS which provides a wrapper for Webpack Encore bundle's encoreEntryLinkTags() and encoreEntryScriptTags() functions, allowing a developer to use those functions in .html5 templates as well.


NOTE: Webpack Encore Bundle requires output_path config to be set. If you do not yet have Webpack Encore Bundle installed, Contao-Encore Bridge will add it to your application automatically, so be sure to set output_path in your config.yml file before installation:

# config/config.yml
    output_path: '%kernel.project_dir%/public/build'

Then install Contao-Encore Bridge:

composer require ameotoko/contao-encore-bridge


Configure your Webpack Encore as described in official docs:


Assuming you have configured your Webpack entrypoint like this:

// webpack.config.js
const Encore = require('@symfony/webpack-encore');

  .addEntry('app', './frontend/js/app.js')

you can now output all stylesheets and scripts for that entry in your .html5 templates, e.g. in fe_page.html5:

<!DOCTYPE html>
<html lang="<?= $this->language ?>"<?php if ($this->isRTL): ?> dir="rtl"<?php endif; ?>>
    <?= $this->encoreEntryLinkTags('app') ?>
    <?= $this->mootools ?>
    <?= $this->encoreEntryScriptTags('app') ?>

Or add them from any other template like so:

<?php $this->extend('ce_gallery'); ?>

<?php $this->block('content'); ?>
    <?php $this->parent(); ?>

    <?php $GLOBALS['TL_CSS'][] = $this->encoreEntryLinkTags('app'); ?>
    <?php $GLOBALS['TL_BODY'][] = $this->encoreEntryScriptTags('app'); ?>
<?php $this->endblock(); ?>