diff --git a/lib/modules/webserver/server.js b/lib/modules/webserver/server.js index 340f5307c..c0d8d94f9 100644 --- a/lib/modules/webserver/server.js +++ b/lib/modules/webserver/server.js @@ -1,9 +1,15 @@ let finalhandler = require('finalhandler'); +const fs = require('../../core/fs.js'); let http = require('http'); let serveStatic = require('serve-static'); const {canonicalHost, defaultHost, dockerHostSwap} = require('../../utils/host'); +const utils = require('../../utils/utils.js'); require('http-shutdown').extend(); +require('ejs'); +const embark_building_placeholder = require('../code_generator/code_templates/embark-building-placeholder.html.ejs'); + +let isFirstStart = true; class Server { constructor(options) { this.dist = options.dist || 'dist/'; @@ -24,6 +30,12 @@ class Server { serve(req, res, finalhandler(req, res)); }).withShutdown(); + if (isFirstStart) { + const html = embark_building_placeholder({buildingMsg: __('Embark is building, please wait...')}); + fs.mkdirpSync(this.dist); // create dist/ folder if not already exists + fs.writeFileSync(utils.joinPath(this.dist, 'index.html'), html); + isFirstStart = false; + } this.server.listen(this.port, this.hostname, () => { this.port = this.server.address().port;