Open barbuslex opened 1 year ago
Hi!
Yea, your setup is a bit more complex :). Have you tried the 2nd argument to encore_entry_link_tags()
? That is the asset package name - so try passing coloradmin
there: https://github.com/symfony/webpack-encore-bundle/blob/2.x/src/Twig/EntryFilesTwigExtension.php#L57C21-L57C42
Also, you could try calling the encore_entry_css_files()
Twig function instead, looping over it, and using the asset()
function manually on those. I believe the CSS files in that loop will start with a /
, so I think you may need to strip the starting /
off so that the asset()
function does its normal job.
Hi @weaverryan, thanks for you reply...
It seems to me that I had an error like "the package name coloradmin does not exist" or something like this. I followed the documentation (https://symfony.com/doc/current/frontend/encore/advanced-config.html#defining-multiple-webpack-configurations) for this setup.
I'll test your solution tomorrow to see...
Hi @weaverryan,
I have tested by replacing {{ asset('coloradmin.js', 'coloradmin')}}
by encore_entry_link_tags('coloradmin', 'coloradmin')
, here the error :
But with encore_entry_link_tags('coloradmin', 'coloradmin', 'coloradmin')
it's works very well, i don't understand why ^^
Thanks
Hi @barbuslex, Your configuration is somewhat confusing because you defined a build folder name that is the same as your entry point and your asset package name. If you take a look at : https://github.com/symfony/webpack-encore-bundle/blob/2.x/src/Twig/EntryFilesTwigExtension.php#L51
I think it's
{{ encore_entry_link_tags('coloradmin', 'coloradmin', 'coloradmin') }}
{{ encore_entry_script_tags('coloradmin', 'coloradmin', 'coloradmin') }}
the third parameter is your entrypointName
-> coloradmin
instead _default
.
which explains why it looks for your entrypoints.json
file in public/build
which is the default directory instead of the directory you defined %kernel.project_dir%/public/bundles/coloradmin
Hi @lhapaipai,
Thanks you for your reply... I think I'm starting to understand...
How can I enter a packageName as coloradmin
and leave the entrypoint as _default
?
Thanks
Hi,
I have this config in a template bundle :
webpack.config.js
webpack_encore.yaml
When i use
{{ asset('coloradmin.css', 'coloradmin') }}
the path generated is/bundles/coloradmin/coloradmin.464b2fc0.css
. When i use{{ encore_entry_link_tags('coloradmin.css', null, 'coloradmin')
the path generated is/coloradmin.464b2fc0.css
.Same with scripts tags/functions.
Have you a workaround for considering base_path parameter with webpack encore functions ? (i need to use env variable from parent root project (inexist env in bundle)).
Thanks