Various fixes
This commit is contained in:
47
lib/serve.js
47
lib/serve.js
@@ -1,26 +1,27 @@
|
||||
module.exports = async (config) => {
|
||||
let isReady = false;
|
||||
const
|
||||
http = require('http'),
|
||||
let isReady = false;
|
||||
const http = require("http"),
|
||||
address = require("network-address"),
|
||||
handler = require("serve-handler"),
|
||||
build = require("./build"),
|
||||
{
|
||||
build: buildOpts,
|
||||
logFunction: log = () => {},
|
||||
serve: serveOpts,
|
||||
} = config || {},
|
||||
{ outputPath, srcPath } = buildOpts || {},
|
||||
{ port = 5000 } = serveOpts || {},
|
||||
server = http.createServer((request, response) => {
|
||||
// You pass two more arguments for config and middleware
|
||||
// More details here: https://github.com/vercel/serve-handler#options
|
||||
return handler(request, response, { public: outputPath });
|
||||
});
|
||||
|
||||
address = require('network-address'),
|
||||
handler = require('serve-handler'),
|
||||
await build(config);
|
||||
|
||||
build = require('./build'),
|
||||
|
||||
{ build: buildOpts, logFunction: log = () => {}, serve: serveOpts } = config || {},
|
||||
{ outputPath, srcPath } = buildOpts || {},
|
||||
{ port = 5000 } = serveOpts || {},
|
||||
|
||||
server = http.createServer((request, response) => {
|
||||
// You pass two more arguments for config and middleware
|
||||
// More details here: https://github.com/vercel/serve-handler#options
|
||||
return handler(request, response, { public: outputPath });
|
||||
});
|
||||
|
||||
await build(config);
|
||||
|
||||
server.listen(port, async () => {
|
||||
log(`Running at http://${address()}:${port} / http://localhost:${port}`);
|
||||
});
|
||||
};
|
||||
server.listen(port, async () => {
|
||||
log(
|
||||
`Running at http://${address()}:${port} / http://localhost:${port}`
|
||||
);
|
||||
});
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user