Search code examples
vue-cli-3

I want vue-cli3 to output html with relative link


I not good at config webpack. So I am using vue-cli3 to create a project without change any congfigrations.

When I build the project, it create a /dist folder and index.html. The index.html use absolutely link such as src=/js/app-legacy.69c62d1a.js to link resources.

Fro some reasons, I want links are relative such as src=./js/app-legacy.69c62d1a.js.

What can I do ?


Solution

  • You can create a vue.config.js file inside the project root folder to configure webpack.

    If you want relative paths, it should look something like this:

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

    You can find more information in the Configuration Reference.