Can I tell browser-sync to always use one .html file? (for html5mode links)
You can use https://github.com/tinganho/connect-modrewrite.
var modRewrite = require('connect-modrewrite');
gulp.task('serve', function () {
browserSync.init(null, {
server: {
baseDir: [APP_PATH],
middleware: [
modRewrite([
'!\\.\\w+$ /index.html [L]'
])
]
}
});
// watch only for app specific codes;
...
});
From https://github.com/BrowserSync/browser-sync/issues/204#issuecomment-102623643
First install connect-history-api-fallback
:
npm --save-dev install connect-history-api-fallback
Then add it to your gulpfile.js:
var historyApiFallback = require('connect-history-api-fallback');
gulp.task('serve', function() {
browserSync.init({
server: {
baseDir: "app",
middleware: [ historyApiFallback() ]
}
});
});