Vue-cli: vue.config.js's baseUrl not working!

Created on 12 Sep 2018  路  5Comments  路  Source: vuejs/vue-cli

Version

3.0.2

Reproduction link

https://github.com/vuejs/vue-cli/files/2373799/2.1.0.zip

Node and OS info

Node 811.1 /npm5.6.0 / Windows 10

Steps to reproduce

I just create vue.config.js and

module.exports = {
  baseUrl: './'
};

then I build , check the index.html

What is expected?

I want the relative path like <link href=./js/about.2b2e4615.js rel=prefetch>

What is actually happening?

<head>
  <meta charset=utf-8>
  <meta http-equiv=X-UA-Compatible content="IE=edge">
  <meta name=viewport content="width=device-width,initial-scale=1">
  <link rel=icon href=favicon.ico>
  <title>2.1.0</title>
  <link href=js/about.2b2e4615.js rel=prefetch>
  <link href=css/app.00caf2cc.css rel=preload as=style>
  <link href=js/app.a7581183.js rel=preload as=script>
  <link href=js/chunk-vendors.25414c9d.js rel=preload as=script>
  <link href=css/app.00caf2cc.css rel=stylesheet>
</head>

Most helpful comment

@hezhongfeng change baseUrl to publicPath

All 5 comments

@parox2014
notice the ./

./ are redundant in relative paths.

I have the same issue. I cannot apply "./" to the baseUrl, it will be ignored,
I disagree that "./" are redundant. Like in my case, if you upload the project to a specific path e.g. origin/pathname/index.html you need to the that otherwise all the files will be referred to the origin and not to the directory where it is placed.
Could you please fix it.

@ebastuart
They are redundant, indeed.
You can try it out yourself.

See https://developer.mozilla.org/en-US/docs/Learn/Common_questions/What_is_a_URL#Examples_of_relative_URLs

@hezhongfeng change baseUrl to publicPath

Was this page helpful?
0 / 5 - 0 ratings