webpack-encore-bundle未知“encore_entry_script_tags”函数

Issue is with symfony 4, php 7.3.7.

I have ran composer require symfony/webpack-encore-bundle and added the default webpack.config.js as recommend in the documentation.

When I add {{ encore_entry_script_tags('app') }} to my base.html.twig I get an error saying that the function is unknown.

Google is leading me nowhere and the documentation says that it is good to go right out of the box if you have symfony flex, which I do.

I tried adding a webpack_encore.yaml to config/packages but it threw an error saying that there is no package to build with this configuration.

Any ideas what I could be missing?

please be sure your config/bundles.php has this line.

return [
    ...
    Symfony\WebpackEncoreBundle\WebpackEncoreBundle::class => ['all' => true],
    ...
];

also check 'config/packages/webpack_encore.yaml' is exist. Here is default config.

webpack_encore:    
    output_path: '%kernel.project_dir%/public/build'