jiiabami yumeko
jiiabami yumeko

Reputation: 79

webpack vue build: how do i remove additional '/' in every link when build

Ok i know this is stupid question. but i really frustated about it. iam currently making project use vue via vue-cli.
this is webpack build result

<!DOCTYPE html>
 <html>
  <head>
  <meta charset=utf-8>
  <meta name=viewport content="width=device-width,initial-scale=1">
  <title>media-belajar</title>
  <link href=/static/css/app.cca059254702f9ed953b7df749673cf4.css rel=stylesheet>
  </head>
<body>
 <div id='app'></div>
  <script type=text/javascript src=/static/js/manifest.2ae2e69a05c33dfc65f8.js></script>
  <script type=text/javascript src=/static/js/vendor.2420502e2b2c7f321d64.js></script>
 <script type=text/javascript src=/static/js/app.f16ac5c624284d30f5af.js>   </script>
</body>

</html>

look at every link it has additional '/' for every link: /static. and it's makes assets won't loaded.

Upvotes: 5

Views: 2221

Answers (3)

Caitlin Morris
Caitlin Morris

Reputation: 899

The linked document says the new recommended solution is to use publicPath instead of baseUrl:

// vue.config.js
    module.exports = {
        publicPath: ''
    }

I recently hosted a Vue app in IIS, and the above file/code resolved all the 404 errors I was getting.

Upvotes: 9

Yuriy
Yuriy

Reputation: 93

You need to create vue.config.js file in your project root and put following content in it:

// vue.config.js
module.exports = {
    baseUrl: ''
}

Read more at the Vue documentation

Upvotes: 0

S&#248;lve
S&#248;lve

Reputation: 4396

You can edit the assetsPublicPath option in your /config/index.js file.

From this: assetsPublicPath: '/'

To this: assetsPublicPath: ''

This should remove the prefixed slash

Upvotes: 1

Related Questions