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: './'

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