Integration with your php and twig application & Webpack Encore!

v1.8.0.2 2020-11-16 16:06 UTC


A very basic and simple implementation of WebpackEncoreBundle for projects that do not use Symfony, with easier setup and less dependencies. Recommended for old projects or projects that do not plan to add or setup Symfony. The frontend setup is the same as with Webpack Encore

Install with:

composer require rodrigoq/simple-webpack-encore-bundle


In your twig setup file:

    use Simple\WebpackEncoreBundle\Twig\EntryFilesTwigExtension;
    $entrypointJsonFile = "path/to/entrypoints.json";
    $twigEnvironment->addExtension(new EntryFilesTwigExtension($entrypointJsonFile));

or for multiple builds:

    use Simple\WebpackEncoreBundle\Twig\EntryFilesTwigExtension;
    $builds = [
        'firstConfig' => "path/to/firstConfig/entrypoints.json",
        'secondConfig' => "path/to/secondConfig/entrypoints.json",
    $twigEnvironment->addExtension(new EntryFilesTwigExtension($builds));

No need for yaml configuration file.


Check readme on the original repo.


Added two new twig functions for full URL or directory prefixing, you can have a full path or different paths configured in php not needing for code on your javascript configuration file.

    {{ encore_entry_script_tags_with_baseurl('app', '') }}
    {{ encore_entry_link_tags_with_baseurl('app', '') }}

    {# or any directory prefix #}

    {{ encore_entry_script_tags_with_baseurl('app', '/a/different/path') }}
    {{ encore_entry_link_tags_with_baseurl('app', '/a/different/path') }}