Hamed.A
Hamed.A

Reputation: 51

Symfony webpack encore twig functions not working

I am generating static html pages using twig in a Symfony 4 project. Am trying to generate multiple pages at the same time with a simple loop and the Twig render function. Code looks like this:

foreach ($pages as $page) {
  $html = $this->twig->render('template', $page);
  $fileSystem->dumpFile('fileName', $html);
}

In the template am using, I load assets via webpack encore twig functions encore_entry_script_tags and encore_entry_link_tags.

The problem I face is that the assets are loaded for the first generated page but not the others ! The generated html content does not contain script and style tags.

I thought about possible Twig cache problem so I set the cache to false but that didn't solve the problem. Also, the problem is gone when I use the standard twig function {{ asset() }} instead of webpack enore twig functions.

Any ideas ?!

Upvotes: 3

Views: 2476

Answers (1)

Hamed.A
Hamed.A

Reputation: 51

Problem found and solved. Check this link out for details. It's kinda a 'bug', the team still working on at the time I write this. A workaround is presented on the link.

Upvotes: 2

Related Questions