refactor: Remove babel/register for instant production server startup (#1481)

* refactor: Remove babel/register for instant production server startup

* fix: Update procfile location

* fix: package.json must be copied, not linked for production build

* fix: Production file paths

* fix: Public assets path

* Remove unused scripts
This commit is contained in:
Tom Moor
2020-09-13 10:46:33 -07:00
committed by GitHub
parent 450d6b7e42
commit 608be3deef
14 changed files with 305 additions and 289 deletions

View File

@@ -18,7 +18,7 @@ const readFile = util.promisify(fs.readFile);
const readIndexFile = async (ctx) => {
if (isProduction) {
return readFile(path.join(__dirname, "../dist/index.html"));
return readFile(path.join(__dirname, "../app/index.html"));
}
const middleware = ctx.devMiddleware;
@@ -39,7 +39,7 @@ const readIndexFile = async (ctx) => {
// serve static assets
koa.use(
serve(path.resolve(__dirname, "../public"), {
serve(path.resolve(__dirname, "../../public"), {
maxage: 60 * 60 * 24 * 30 * 1000,
})
);
@@ -52,10 +52,7 @@ if (process.env.NODE_ENV === "production") {
"Cache-Control": `max-age=${356 * 24 * 60 * 60}`,
});
await sendfile(
ctx,
path.join(__dirname, "../dist/", ctx.path.substring(8))
);
await sendfile(ctx, path.join(__dirname, "../app/", ctx.path.substring(8)));
});
}