|
|
@ -40,6 +40,7 @@ buildScriptFiles() |
|
|
|
|
|
|
|
|
let port = 3000; |
|
|
let port = 3000; |
|
|
let externalUrl = ''; |
|
|
let externalUrl = ''; |
|
|
|
|
|
let previewFrameUrl = `http://localhost:${port}`; |
|
|
const app = express(); |
|
|
const app = express(); |
|
|
|
|
|
|
|
|
const hbs = create({ |
|
|
const hbs = create({ |
|
|
@ -71,13 +72,14 @@ app.get('/', async (req, res) => { |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
const baseView = config.has('baseView') ? config.get('baseView') : 'container'; |
|
|
const baseView = config.has('baseView') ? config.get('baseView') : 'container'; |
|
|
|
|
|
const baseViewUrl = `view/${baseView}`; |
|
|
|
|
|
|
|
|
data.helpers = { |
|
|
data.helpers = { |
|
|
port, |
|
|
port, |
|
|
include_partial: (path) => projectDir + path, |
|
|
include_partial: (path) => projectDir + path, |
|
|
baseView: baseView, |
|
|
baseView, |
|
|
externalUrl: `${externalUrl}/view/${baseView}`, |
|
|
externalUrl: `${externalUrl}/${baseViewUrl}`, |
|
|
previewFrameUrl: `http://localhost:${port}/view/${baseView}`, |
|
|
previewFrameUrl: `${previewFrameUrl}/${baseViewUrl}`, |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
res.render('index', data); |
|
|
res.render('index', data); |
|
|
@ -210,8 +212,10 @@ const listener = app.listen(0, async () => { |
|
|
proxy: `http://localhost:${PORT}`, |
|
|
proxy: `http://localhost:${PORT}`, |
|
|
open: false |
|
|
open: false |
|
|
}, (err, bs) => { |
|
|
}, (err, bs) => { |
|
|
externalUrl = bs.getOptionIn(["urls"]).get('external'); |
|
|
const options = bs.getOptions().toJS(); |
|
|
port = bs.server._connectionKey.split(':').pop(); |
|
|
previewFrameUrl = options.urls.external; |
|
|
|
|
|
externalUrl = previewFrameUrl.replace(options.port, options.proxy.url.port); |
|
|
|
|
|
port = options.port; |
|
|
}); |
|
|
}); |
|
|
|
|
|
|
|
|
}); |
|
|
}); |
|
|
|