Making page404 with gulp gulp-server-livereload. This works well on localhost. But when published on github pages it doesn't. Simply "Failed to load resource: the server responded with a status of 404 ()".
const gulp = require("gulp");
const fileInclude = require("gulp-file-include");
const sass = require("gulp-sass")(require("sass"));
const sassGlob = require("gulp-sass-glob");
const server = require("gulp-server-livereload");
const clean = require("gulp-clean");
const fs = require("fs");
const sourceMaps = require("gulp-sourcemaps");
const plumber = require("gulp-plumber");
const notify = require("gulp-notify");
const webpack = require("webpack-stream");
const babel = require("gulp-babel");
const imagemin = require("gulp-imagemin");
const changed = require("gulp-changed");
....
const serverOptions = {
livereload: true,
open: true,
fallback: '/notFound.html',
};
gulp.task("server:dev", function () {
return gulp.src("./build/").pipe(server(serverOptions));
});
I've tried to use historyApiFallback for routing to page 404 but failed even on localhost.
const historyApiFallback = require('connect-history-api-fallback');
gulp.task('server:dev', function () {
browserSync.init({
server: {
baseDir: './build/',
middleware: [historyApiFallback({
index: '/index.html',
rewrites: [
{ from: /\/.*/, to: '/notFound.html' }
})],
},
port: 3000,
});