最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - webpack vue build: how do i remove additional '' in every link when build - Stack Overflow

programmeradmin1浏览0评论

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/appa059254702f9ed953b7df749673cf4.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.

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/appa059254702f9ed953b7df749673cf4.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.

Share Improve this question asked Aug 5, 2018 at 10:56 jiiabami yumekojiiabami yumeko 794 bronze badges 0
Add a ment  | 

3 Answers 3

Reset to default 9

The linked document says the new remended 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.

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

From this: assetsPublicPath: '/'

To this: assetsPublicPath: ''

This should remove the prefixed slash

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

发布评论

评论列表(0)

  1. 暂无评论