Starting Node.js server w/ Gulp “connect” breaks on live reload (Angular app w/ html5 mode)

China☆狼群 提交于 2019-12-06 05:15:18

Here is a fairly good solution :)

Here is what you should use:

gulp.task('connect', connect.server({
  root: ['build'],
  port: 9000,
  livereload: true,
  open: {
    browser: 'Google Chrome'
  },
   middleware: function(connect, opt) {
      return [ historyApiFallback ];
    }
}));

This is the module i use for SPA development:

"connect-history-api-fallback": "0.0.5",

Also AngularJs has a neat solution for avoiding setting base href

$locationProvider.html5Mode({enabled: true, requireBase: false})
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!