vue-cli打包之後的dist文件無法運行index.html

vue版本

"vue": "^2.5.2","webpack": "^3.6.0",

問題

打包之後的 dist 文件下面包含 static 文件和 index.html 文件,直接打開index.html文件爲空白,控制檯會有很多錯誤

解決方法

build/util.js

    if (options.extract) {
      return ExtractTextPlugin.extract({
        use: loaders,
        publicPath:'../../',   //添加這句
        fallback: 'vue-style-loader'
      })
    } else {
      return ['vue-style-loader'].concat(loaders)
    }
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9

config/index.js
將文件中的兩個assetsPublicPath: '/'改爲assetsPublicPath: './'

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章