我尝试设置资源的相对路径
.setPublicPath('build/')
但是当编译时我得到
The value passed to setPublicPath() should *usually* start with "/" or be a full URL (http://...). If you're not sure, then you should probably change your public path and make this message disappea
和生成链接
{% block javascripts %}
{{ encore_entry_script_tags('app') }}
{% endblock %}
和
<script src="/build/runtime.js" defer></script>
<script src="/build/vendors~app.js" defer></script>
<script src="/build/app.js" defer></script>
I need build/not/build/
我有服务器与文件夹为基础的应用程序,所以为什么不能像我想要的安装补丁。我知道,当应用程序使用路由/aa/bb/cc这停止工作。但是这个应用只有一页。一个链接所有请求是ajax。
就像消息"should通常以"/";
我找到了可行的解决方案
https://symfony.com/doc/current/frontend/encore/faq.html
.setOutputPath('public/build/')
- .setPublicPath('/build')
+ // this is your *true* public path
+ .setPublicPath('/myAppSubdir/build')
+ // this is now needed so that your manifest.json keys are still `build/foo.js`
+ // (which is a file that's used by Symfony's `asset()` function)
+ .setManifestKeyPrefix('build')
我从env中读取myAppSubdir,几乎是动态的。