vue-cli4.5项目发布上线,页面空白,控制台404

在本地正常,部署到线上之后页面空白,vue-cli为4.5版本,控制台Failed to load resource: the server responded with a status of 404 (Not Found)。请大佬帮忙看看

vue.config.js

module.exports = {
    // publicPath: process.env.NODE_ENV === 'production'
    // ? './'
    // : '/',
    // outputDir: 'dist',
    chainWebpack: config => {
        //发布模式
        config.when(process.env.NODE_ENV === 'production', config => {
            //entry找到默认的打包入口,调用clear则是删除默认的打包入口
            //add添加新的打包入口
            config.entry('app').clear().add('./src/main-prod.js')

            //使用externals设置排除项
            config.set('externals', {
                vue: 'Vue',
                'vue-router': 'VueRouter',
                axios: 'axios',
                lodash: '_',
                echarts: 'echarts',
                nprogress: 'NProgress',
                'vue-quill-editor': 'VueQuillEditor'
            })

            config.plugin('html').tap(args => {
                args[0].isProd = true
                return args
            })
        })

        //开发模式
        config.when(process.env.NODE_ENV === 'development', config => {
            config.entry('app').clear().add('./src/main-dev.js')

            config.plugin('html').tap(args => {
                args[0].isProd = false
                return args
            })
        })
    }
}

index.js

import Vue from 'vue'
import VueRouter from 'vue-router'

// import Login from '../components/Login.vue'
// import Home from '../components/Home.vue'
// import Welcome from '../components/Welcome.vue'
// import Users from '../components/user/Users.vue'
// import Rights from '../components/power/Rights.vue'
// import Roles from '../components/power/Roles.vue'
// import Cate from '../components/goods/Cate.vue'
// import Params from '../components/goods/Params.vue'
// import GoodsList from '../components/goods/GoodsList.vue'
// import Add from '../components/goods/Add.vue'
// import Order from '../components/order/Order.vue'
// import Report from '../components/report/Report.vue'

const Login = () => import(/* webpackChunkName:"login_home_welcome" */ '../components/Login.vue')
const Home = () => import(/* webpackChunkName:"login_home_welcome" */ '../components/Home.vue')
const Welcome = () => import(/* webpackChunkName:"login_home_welcome" */ '../components/Welcome.vue')
const Users = () => import(/* webpackChunkName:"Users_Rights_Roles" */ '../components/user/Users.vue')
const Rights = () => import(/* webpackChunkName:"Users_Rights_Roles" */ '../components/power/Rights.vue')
const Roles = () => import(/* webpackChunkName:"Users_Rights_Roles" */ '../components/power/Roles.vue')
const Cate = () => import(/* webpackChunkName:"Cate_Params" */ '../components/goods/Cate.vue')
const Params = () => import(/* webpackChunkName:"Cate_Params" */ '../components/goods/Params.vue')
const GoodsList = () => import(/* webpackChunkName:"GoodsList_Add" */ '../components/goods/GoodsList.vue')
const Add = () => import(/* webpackChunkName:"GoodsList_Add" */ '../components/goods/Add.vue')
const Order = () => import(/* webpackChunkName:"Order_Report" */ '../components/order/Order.vue')
const Report = () => import(/* webpackChunkName:"Order_Report" */ '../components/report/Report.vue')


Vue.use(VueRouter)

const routes = [
]

const router = new VueRouter({
  base: '/',
  mode: 'hash',
  build: {
  //   index: path.resolve(__dirname, '../dist/index.html'),
  //   assetsRoot: path.resolve(__dirname, '../dist'),
    assetsSubDirectory: 'static',
    assetsPublicPath: './'
  },
  routes: [
    { path: '/', redirect: '/login' },
    { path: '/login', component: Login },
    {
      path: '/home',
      component: Home,
      redirect: '/welcome',
      children: [{ path: '/welcome', component: Welcome },
      { path: '/users', component: Users },
      { path: '/rights', component: Rights },
      { path: '/roles', component: Roles },
      { path: '/categories', component: Cate },
      { path: '/params', component: Params },
      { path: '/goods', component: GoodsList },
      { path: '/goods/add', component: Add },
      { path: '/orders', component: Order },
      { path: '/reports', component: Report }
      ]
    }
  ]
})

//挂载路由导航守卫
router.beforeEach((to, from, next) => {
  //to代表将要访问的路径
  //from代表从哪个路径跳转而来
  //next是一个函数,表示放行
  //  next() 放行   next('/login') 强制跳转

  if (to.path == '/login') return next();//直接放行
  //获取token
  const tokenStr = window.sessionStorage.getItem('token');
  if (!tokenStr) return next('/login');//强制跳转
  next();

})
export default router

 

不知道你这个问题是否已经解决, 如果还没有解决的话:

如果你已经解决了该问题, 非常希望你能够分享一下解决方案, 以帮助更多的人 ^-^