Vuejs, Difficulties to build with relative path

I know everything has changed from you wrote the post. But at this moment with the last version of Vue and Vue Cli you can get it with the vue config file (I am not an expert in this platform):

  1. Create a "vue.config.js" file at the main path of your project

  2. Give a relative path. Example:

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

It is not working with fonts added in css, I don't know why and I am still googlying. If anyone reading can help will be great.


The absolute path does not have to include the domain name, it just needs to start from the root.

Think about HTML5 URLs. For example, if your static folder is located at http://www.example.com/static and the current url is http://www.example.com/users then the relative path would be ../static. However, if you're trying to see an user's details and go to http://www.example.com/users/john-doe, the relative path would be ../../static. You can't load the assets if you don't know where they are, that's why you need a starting point, an absolute URL.

What's the problem you're afraid of? Can you be more specific?


I have solved my problem with the following vue.config.js settings:

module.exports = {
    publicPath: process.env.BASE_URL,
    assetsDir: process.env.BASE_URL
};

I think you can do the same with webpack.config.js as well by changing output.publicPath. Reference: https://cli.vuejs.org/guide/html-and-static-assets.html#url-transform-rules

You can also do publicPath: process.env.BASE_URL + '/static/'