Vue-CLI 3.0-如何更改生产链接?

时间:2018-08-27 11:43:26

标签: vue.js webpack vue-cli vue-cli-3

默认情况下,在dist / index.html中创建了此类链接:

<link href=/js/app.2e806e0c.js rel=preload as=script>
<link href=/js/chunk-vendors.bc9ee6a2.js rel=preload as=script>
<link href=/css/chunk-vendors.fc712ce5.css rel=stylesheet>
<link href=/css/app.64eef18a.css rel=stylesheet>
<script src=/js/chunk-vendors.bc9ee6a2.js></script>
<script src=/js/app.2e806e0c.js></script>

如何更改与此链接?

<link href=js/app.2e806e0c.js rel=preload as=script>
<link href=js/chunk-vendors.bc9ee6a2.js rel=preload as=script>
<link href=css/chunk-vendors.fc712ce5.css rel=stylesheet>
<link href=css/app.64eef18a.css rel=stylesheet>
<script src=js/chunk-vendors.bc9ee6a2.js></script>
<script src=js/app.2e806e0c.js></script>

2 个答案:

答案 0 :(得分:3)

有关 Vue CLI 3.3 + ,请参阅@DoronG's answer below


您可以通过baseUrl选项更改此选项,必须在项目根目录的vue.config.js文件中进行设置:

module.exports = {
  baseUrl: ''
};

答案 1 :(得分:1)

@yuriy636之后回答,baseUrl现在为deprecated,您应该改用publicPath

module.exports = {
  publicPath: ""
};