VUE项目部署到线上生产环境,Loading chunk xxx failed

项目部署到生产环境,路由点击无效,报错 Loading chunk chunk-xxxxx failed。(missing xxxx)

加载失败,错误的路径。

话不多说,直接贴代码: vue.config.js 配置文件

/**
 * 配置参考: https://cli.vuejs.org/zh/config/
 */
module.exports = {
  // publicPath: process.env.NODE_ENV === 'production' ? './' : '/',
  publicPath: '/', //重点,生产环境的路径也改成 '/' 即可
  // eslint效验,在非生产环境为校验
  lintOnSave: process.env.NODE_ENV !== 'production',
  productionSourceMap: false,
  devServer: {
    port: 8888,
    overlay: {
      errors: true,
      warnings: true
    }
  }
}

之后再打包上线,访问,ok,没问题了。

 

posted @ 2020-12-24 17:12  lpmou  阅读(1824)  评论(0编辑  收藏  举报
返回顶部