简体   繁体   English

Vue.js 构建器在索引中生成不正确的路径。html

[英]Vue.js builder produces incorrect paths in index.html

The problem is that after building vue app in destination folder there is index.html with incorrect paths to static assets.问题是在目标文件夹中构建 vue 应用程序后, index.html 与 static 资产的路径不正确。 Links look like链接看起来像

<link href="/static/js/chunk-29e00bf1.49e28fbb.js" rel="prefetch">

which is incorrect, but should be这是不正确的,但应该是

<link href="static/js/chunk-29e00bf1.49e28fbb.js" rel="prefetch">

And browser look into ///D:/static/js/ instead of D://.../build/dist/static/js.并且浏览器查看 ///D:/static/js/ 而不是 D://.../build/dist/static/js。

There is my vue.config.js有我的 vue.config.js

module.exports = {
  outputDir: './build/dist/',
  assetsDir: './static', //...

Use publicPath property, and set the path to ./ to use relative paths on build.使用publicPath属性,并将路径设置为./以在构建时使用相对路径。

module.exports = {
    ...
    publicPath: "./"
    ...
}

Read more in the official documentation: publicPath在官方文档中阅读更多信息: publicPath

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM