php - how - webpack encore



Symfony 4, include assets from vendor directory (1)

Before, Assets used to compile all your selected files into one with the current version in the file name, but it changes from Symfony 4

According to those documentation

https://symfony.com/doc/current/frontend.html

https://symfony.com/doc/current/frontend/encore/bootstrap.html

You should use Webpack Encore and be able to use the new system of Asset

I would like to load vendor assets, downloaded with composer inside vendor directory, from my twig template.

Using a relative path is one solution (in this example I'm going to include bootstrap css, but the same problem is for any other libs required from composer, as jQuery, jQueryUI etc. )

<link rel="stylesheet" href="{{ asset('../vendor/twbs/bootstrap/dist/css/bootstrap.min.css') }}" >

Symfony docs suggest to use asset:install in order to generate a symlink from vendor directory to public, but I was unable to understand how it works. assets:install -h wasn't so clear to let me understand how to link a specific vendor path to the public directory.

Creating a simlink with

ln -s /path/of/vendor/lib /path/public/dir

works fine but, symlinks created will be deleted every time I look for an update with composer.

Any idea about "a best practice" to include assets from vendor directory?

Thank you





bootstrap-4