diff --git a/package.json b/package.json index a8a816c..684f186 100644 --- a/package.json +++ b/package.json @@ -4,7 +4,9 @@ "description": "portfolio", "main": "index.js", "scripts": { - "build": "NODE_ENV=production webpack -p --progress", + "build": "npm run build-client && npm run build-server", + "build-client": "NODE_ENV=production webpack --config webpack.client.js -p --progress", + "build-server": "NODE_ENV=production webpack --config webpack.server.js -p --progress", "start": "NODE_ENV=production node ./build/server.js", "start-dev": "NODE_ENV=development babel-node ./src/server.js" }, @@ -17,6 +19,7 @@ "dependencies": { "async": "^2.5.0", "express": "^4.13.4", + "express-static-gzip": "^1.1.3", "front-matter": "^2.2.0", "jsonfile": "^4.0.0", "markdown-it": "^8.4.2", diff --git a/src/server.js b/src/server.js index e907684..db4d478 100644 --- a/src/server.js +++ b/src/server.js @@ -1,4 +1,5 @@ import express from 'express' +import expressStaticGzip from 'express-static-gzip' import { serverRender } from './utils/serverRender' import { Scanner } from './utils/scanner' @@ -8,7 +9,7 @@ const app = express() const scanner = new Scanner() scanner.scan() -app.use('/static', express.static('public/static')) +app.use('/static', expressStaticGzip('public/static')) app.get('/favicon.ico', (req, res) => { res.status(404).send('Not Found !!!') diff --git a/src/utils/serverRender.js b/src/utils/serverRender.js index dd57588..a4f7628 100644 --- a/src/utils/serverRender.js +++ b/src/utils/serverRender.js @@ -4,6 +4,7 @@ import { StaticRouter as Router, matchPath } from 'react-router-dom' import { App } from '../components' import routes from './routes' import serialize from 'serialize-javascript' +import manifest from '../../public/static/manifest.json' export function serverRender (req, res, next) { const activeRoute = routes.find((route) => matchPath(req.url, route)) || {} @@ -34,13 +35,13 @@ function renderFullPage (html, data) { - +