In the following express/gulpfile.js code, I am having an issue with express serving the index.html
fine but the index itself cannot hit the lib/*
directory and just 404s all the requests made at the top of my index.html
.
I am proxying browser-sync with nodemon. However I'm pretty sure it has nothing to do with my browser-sync config because when I just use node config/server.js
the same problem persists.
Express config:
var express = require('express');var path = require('path');var filePaths = require('./filePaths');var app = express();//filePaths.releaseIndex === './release/index.html'app.get('/', function (req, res) { res.sendFile(filePaths.releaseIndex, {root: './'});});app.listen(5000);
Gulp task config:
//filePaths.release === './release'//filePaths.server === './config/server.js'gulp.task('browser-sync', ['nodemon'], function() { browserSync.init(null, { proxy: "http://localhost:5000", files: [filePaths.release], browser: "google chrome", port: 7000 });});gulp.task('nodemon', function (cb) { var started = false; return nodemon({ script: filePaths.server }).on('start', function () { if (!started) { cb(); started = true; } });});
index.html:
<script src="lib/es6-shim.min.js"></script>
Folder structure:
config server.jsrelease index.html lib es6-shim.min.js Rx.js ...
I've tried many different variations in the res.sendFile()
but just can't get a foothold although I am sure that it is the problem.
Any ideas?