Unknown “encore_entry_link_tags” function when using Webpack Encore ^0.21.0

狂风中的少年 提交于 2020-01-21 06:39:39

问题


I would like to use the new version of Webpack encore to have access to all the new features it offers. however after following the steps in the official guide I can't make it to work and I get Unknown "encore_entry_link_tags" function

What I did:

  1. Update my php version to match requierement of Webpack encore bundle (>7.1.9)
  2. run composer require symfony/webpack-encore-bundle
  3. update the version of encore on the package.json 0.21.0
  4. run npm install --save-dev
  5. clear cache

I'm not sure why this is not working. Any suggestion would be appreciated.


回答1:


After digging a bit, I found that I omitted some steps (not mentioned on the guide). Maybe it's obvious for others but in my case it was not.

Here are all the steps in order for it to work:

  1. Update my php version to match requierement of Webpack encore bundle (>7.1.9)
  2. run composer require symfony/webpack-encore-bundle
  3. update the version of encore on the package.json 0.21.0
  4. run npm install --save-dev
  5. Add new \Symfony\WebpackEncoreBundle\WebpackEncoreBundle() to your AppKernel.php
  6. Add to your config file

    webpack_encore:
        output_path: "%kernel.root_dir%/../web/build/"
    
  7. clear cache

I don't know why the Symfony team just assumed everyone would know those 2 steps. Hope it helps




回答2:


Just run the following 2 cmds:

composer require symfony/webpack-encore-bundle

composer remove symfony/webpack-encore-pack

This fixed the issue for me, apparently they had upgraded webpack encore package with symfony 4;

Here's some reading:

https://symfony.com/blog/encore-0-21-0-webpack-4-support-copy-files-support-webpackencorebundle




回答3:


I finally got there. I replaced the twig links with the html they are replaced with, seems to work so far.

Replace...

{{ encore_entry_link_tags('app') }}

{{ encore_entry_script_tags('app') }}

...with...

<link rel="stylesheet" href="/build/app.css">

and

<script src="/build/runtime.js"></script>

<script src="/build/app.js"></script>


来源:https://stackoverflow.com/questions/53230674/unknown-encore-entry-link-tags-function-when-using-webpack-encore-0-21-0

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!