使用相对路径发布vue-cli项目

项目根目录添加vue.config.js, 编辑baseUrl

> v3.0.0

项目根目录添加vue.config.js, 编辑baseUrl

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
module.exports = {
// Project deployment base
// By default we assume your app will be deployed at the root of a domain,
// e.g. https://www.my-app.com/
// If your app is deployed at a sub-path, you will need to specify that
// sub-path here. For example, if your app is deployed at
// https://www.foobar.com/my-app/
// then change this to '/my-app/'
baseUrl: '/',

// baseUrl, but for the dev server.
// you'll only need this if you need to serve your dev server under
// a specific sub-path in order to work with your dev setup.
devBaseUrl: '/',

...
}

详见 : 文档

< v3.0.0

  1. config/index.js中,将assetsPublicPath修改为./
  2. build/utils.js中,找到ExtractTextPlugin.extract,添加配置项publicPath: '../../'

参考:
使用相对路径发布vue-cli项目的坑