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,13 +17,18 @@ const router = new Router();
// }
// });
// Frontend
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'));
if (!ctx.status) ctx.throw(httpErrors.NotFound());

View File

@ -1,3 +1,3 @@
// https://github.com/reactjs/react-router/blob/master/docs/guides/NavigatingOutsideOfComponents.md
import { browserHistory } from 'react-router';
import browserHistory from 'react-router/lib/browserHistory';
export default browserHistory;

View File

@ -1,7 +1,9 @@
import React from 'react';
import { render } from 'react-dom';
import { Provider } from 'react-redux';
import { Router, Route, IndexRoute } from 'react-router';
import Router from 'react-router/lib/Router';
import Route from 'react-router/lib/Route';
import IndexRoute from 'react-router/lib/IndexRoute';
import { createStore, applyMiddleware } from 'redux';
import { routerMiddleware } from 'react-router-redux';
import { persistStore, autoRehydrate } from 'redux-persist';