如何使用vue cli build将脚本/样式/图像的源更改为另一个域,例如cdn.example.com
?
例如,在构建之后,我获得index.html的以下内容:
...
<script src=/js/runtime~app.6804cb6b.js></script>
<script src=/js/chunk-vendors.8aaf819c.js></script>
<script src=/js/app.018b8fef.js></script>
</body></html>
预期输出为:
...
<script src=https://cdn.example.com/myapp/js/runtime~app.6804cb6b.js></script>
<script src=https://cdn.example.com/myapp/js/chunk-vendors.8aaf819c.js></script>
<script src=https://cdn.example.com/myapp/js/app.018b8fef.js></script>
</body></html>
vue cli build是否有可能?
答案 0 :(得分:0)
您可以在vue cli配置中更改publicPath
:
publicPath
:您的应用程序捆绑包将部署在的基本URL(在Vue CLI 3.3之前称为baseUrl
)。这等效于webpack的output.publicPath
,但是Vue CLI还需要将此值用于其他目的,因此您应始终使用publicPath
而不是修改webpackoutput.publicPath
。