The problem is that after building vue app in destination folder there is index.html with incorrect paths to static assets. 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.
There is my vue.config.js
module.exports = {
outputDir: './build/dist/',
assetsDir: './static', //...
Use publicPath
property, and set the path to ./
to use relative paths on build.
module.exports = {
...
publicPath: "./"
...
}
Read more in the official documentation: publicPath
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.