From 1d38af1f58d17b3d595c033538a33fb1fd136a1d Mon Sep 17 00:00:00 2001 From: "Michael Bradley, Jr" Date: Fri, 31 Aug 2018 14:51:18 -0500 Subject: [PATCH] expose buildDir to webserver in same manner as its done for pipeline --- lib/core/engine.js | 1 + lib/modules/webserver/index.js | 2 ++ lib/modules/webserver/server.js | 4 ++-- 3 files changed, 5 insertions(+), 2 deletions(-) diff --git a/lib/core/engine.js b/lib/core/engine.js index 37706cd2..822ddf6d 100644 --- a/lib/core/engine.js +++ b/lib/core/engine.js @@ -228,6 +228,7 @@ class Engine { } webServerService(_options) { + _options.buildDir = this.config.buildDir; this.registerModule('webserver', _options); } diff --git a/lib/modules/webserver/index.js b/lib/modules/webserver/index.js index a0b94850..3f335ea8 100644 --- a/lib/modules/webserver/index.js +++ b/lib/modules/webserver/index.js @@ -8,6 +8,7 @@ class WebServer { this.embark = embark; this.logger = embark.logger; this.events = embark.events; + this.buildDir = options.buildDir; this.webServerConfig = embark.config.webServerConfig; if (!this.webServerConfig.enabled) { return; @@ -19,6 +20,7 @@ class WebServer { this.events.emit("status", __("Starting Server")); this.server = new Server({host: this.host, port: this.port}); + buildDir: this.buildDir, this.testPort(() => { this.listenToCommands(); this.registerConsoleCommands(); diff --git a/lib/modules/webserver/server.js b/lib/modules/webserver/server.js index 9c3e9059..73ba07a7 100644 --- a/lib/modules/webserver/server.js +++ b/lib/modules/webserver/server.js @@ -12,7 +12,7 @@ const embark_building_placeholder = require('../code_generator/code_templates/em class Server { constructor(options) { - this.dist = options.dist || 'dist/'; + this.buildDir = options.buildDir; this.port = options.port || 8000; this.hostname = dockerHostSwap(options.host) || defaultHost; this.isFirstStart = true; @@ -26,7 +26,7 @@ class Server { ":" + this.port).bold.underline.green; return callback(null, message); } - let serve = serveStatic(this.dist, {'index': ['index.html', 'index.htm']}); + let serve = serveStatic(this.buildDir, {'index': ['index.html', 'index.htm']}); this.server = http.createServer(function onRequest(req, res) { serve(req, res, finalhandler(req, res));