More selective imports

This commit is contained in:
Jori Lallo
2016-05-07 09:18:20 -07:00
parent 16e972e53c
commit 429e698c26
3 changed files with 15 additions and 8 deletions

View File

@ -17,12 +17,17 @@ const router = new Router();
// }
// });
// Frontend
router.get('/service-worker.js', async (ctx) => {
ctx.set('Content-Type', 'application/javascript');
const stats = await sendfile(ctx, path.join(__dirname, 'static/service-worker.js'));
if (!ctx.status) ctx.throw(httpErrors.NotFound());
});
if (process.env.NODE_ENV === 'production') {
router.get('/service-worker.js', async (ctx) => {
ctx.set('Content-Type', 'application/javascript');
const stats = await sendfile(ctx, path.join(__dirname, 'static/service-worker.js'));
if (!ctx.status) ctx.throw(httpErrors.NotFound());
});
router.get('/static/*', async (ctx) => {
const stats = await sendfile(ctx, path.join(__dirname, '../dist/', ctx.path.substring(8)));
});
}
router.get('*', async (ctx) => {
const stats = await sendfile(ctx, path.join(__dirname, './static/dev.html'));