Vue-cli: The baseUrl option cannot be empty

Created on 28 Feb 2018  路  8Comments  路  Source: vuejs/vue-cli

Version

3.0.0-alpha.13

Steps to reproduce

Make a vue.config.js with

module.exports = {
  baseUrl: ''
}

execute npm run build.

What is expected?

An index.html file is created with relative link, f.e. href=js/... etc.

What is actually happening?

I get an error that baseUrl cannot be empty.


A simple workaround is

module.exports = {
  configureWebpack: {
    output: {
      publicPath: '',
    },
  },
};

This is actually the default value for publicPath, so it is weird that baseUrl does not allow this value.

bug

Most helpful comment

This will be possible in the next release.

All 8 comments

Hmm, publicPath or baseUrl should either be / or .. Does . work for you?

. almost works, there is another bug that generates a url .css/...

@sjoerdvisscher that seems to be a legit bug - can you provide some more details?

I get:

<link rel="shortcut icon" href=.favicon.ico><title>mmm</title><link rel=preload as=script href=.js/vendor.b654b3dd.js><link rel=preload as=script href=.js/app.8878312f.js><link rel=preload as=style href=.css/app.d8788300.css>

The actual stylesheet link and the script src urls are correct. (They start with ./)

But why can't it be the empty string, it's the default for webpack: https://webpack.js.org/configuration/output/#output-publicpath

basePath: './' does work properly, so I'll be using that for now.

Can this issue be reevaluated? Motivation is as follows:

We've tried all permutations of baseUrl values ('', '.', './', '/') and none of these allow the build process to output relative paths (e.g., src="assets/image.png").

To achieve this it seems the baseUrl should be set to '', but this is not allowed currently. What is the reasoning behind this? Is there a way to achieve relative references to assets such as in the example above?

This will be possible in the next release.

Sorry to be a troll, but are the docs just made up then? I dont think I ever heard of premature documentation. https://cli.vuejs.org/config/#baseurl

Was this page helpful?
0 / 5 - 0 ratings

Related issues

DrSensor picture DrSensor  路  3Comments

JIANGYUJING1995 picture JIANGYUJING1995  路  3Comments

BusyHe picture BusyHe  路  3Comments

CodeApePro picture CodeApePro  路  3Comments

Gonzalo2683 picture Gonzalo2683  路  3Comments