Serve static resources from fixed directory, regardless of CWD
This commit is contained in:
parent
724f11cfcb
commit
9b148b43d3
|
@ -3,9 +3,12 @@
|
||||||
const {Server} = require('./server/Server');
|
const {Server} = require('./server/Server');
|
||||||
const {StaticRequestHandler} = require('./server/StaticRequestHandler');
|
const {StaticRequestHandler} = require('./server/StaticRequestHandler');
|
||||||
const {render} = require('./handlers/render');
|
const {render} = require('./handlers/render');
|
||||||
|
const path = require('path');
|
||||||
|
|
||||||
const DEV = process.argv.includes('dev');
|
const DEV = process.argv.includes('dev');
|
||||||
const HOSTNAME = '127.0.0.1';
|
const HOSTNAME = '127.0.0.1';
|
||||||
|
const BASEDIR = path.join(__dirname, '..') + '/';
|
||||||
|
|
||||||
let PORT = Number.parseInt(process.argv[2], 10);
|
let PORT = Number.parseInt(process.argv[2], 10);
|
||||||
if(Number.isNaN(PORT)) {
|
if(Number.isNaN(PORT)) {
|
||||||
PORT = 8080;
|
PORT = 8080;
|
||||||
|
@ -40,7 +43,7 @@ const statics = new StaticRequestHandler('')
|
||||||
|
|
||||||
statics
|
statics
|
||||||
.add('/robots.txt', '')
|
.add('/robots.txt', '')
|
||||||
.addResources('/', '', [
|
.addResources('/', BASEDIR, [
|
||||||
'index.html',
|
'index.html',
|
||||||
'library.htm',
|
'library.htm',
|
||||||
'styles',
|
'styles',
|
||||||
|
@ -51,7 +54,7 @@ statics
|
||||||
], devMapper);
|
], devMapper);
|
||||||
|
|
||||||
if(DEV) {
|
if(DEV) {
|
||||||
statics.addResources('/', '', [
|
statics.addResources('/', BASEDIR, [
|
||||||
'node_modules/requirejs/require.js',
|
'node_modules/requirejs/require.js',
|
||||||
'scripts',
|
'scripts',
|
||||||
'web',
|
'web',
|
||||||
|
|
Loading…
Reference in New Issue