diff --git a/server/routes.js b/server/routes.js index 3c0161f9..8b23d2a3 100644 --- a/server/routes.js +++ b/server/routes.js @@ -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')); diff --git a/src/Utils/History.js b/src/Utils/History.js index 76445fa0..7a86a35d 100644 --- a/src/Utils/History.js +++ b/src/Utils/History.js @@ -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; diff --git a/src/index.js b/src/index.js index de450807..466f829d 100644 --- a/src/index.js +++ b/src/index.js @@ -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';