Add gzip compression
This commit is contained in:
parent
2716b342ed
commit
fa22736644
|
@ -18,6 +18,7 @@
|
|||
"async": "^2.5.0",
|
||||
"axios": "^0.17.0",
|
||||
"express": "^4.13.4",
|
||||
"express-static-gzip": "^0.3.2",
|
||||
"front-matter": "^2.2.0",
|
||||
"jsonfile": "^4.0.0",
|
||||
"markdown-it": "^8.4.0",
|
||||
|
@ -40,6 +41,7 @@
|
|||
"babel-preset-stage-0": "^6.5.0",
|
||||
"babel-register": "^6.7.2",
|
||||
"babel-runtime": "^6.26.0",
|
||||
"compression-webpack-plugin": "^1.1.11",
|
||||
"css-loader": "^0.28.11",
|
||||
"css-modules-require-hook": "^4.0.6",
|
||||
"file-loader": "^1.1.11",
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
require('babel-register');
|
||||
var path = require('path');
|
||||
|
||||
var app = new (require('express'))();
|
||||
var port = process.env.PORT || 3000;
|
||||
|
@ -38,12 +39,14 @@ if (process.env.NODE_ENV === 'development') {
|
|||
app.use(hotDevMiddleware(compiler))
|
||||
}
|
||||
|
||||
app.use(require('express').static('public'));
|
||||
require('./utils/scanner')();
|
||||
|
||||
var api = require('./utils/api');
|
||||
app.use("/api", api);
|
||||
|
||||
var expressStaticGzip = require("express-static-gzip");
|
||||
app.use("/static", expressStaticGzip(path.join(process.cwd(), '/public/static')));
|
||||
|
||||
var serverRender = require('./utils/serverRender');
|
||||
app.get("*", serverRender);
|
||||
|
||||
|
|
|
@ -3,6 +3,7 @@ const webpack = require('webpack')
|
|||
const UglifyJsPlugin = require("uglifyjs-webpack-plugin")
|
||||
const MiniCssExtractPlugin = require("mini-css-extract-plugin")
|
||||
const OptimizeCSSAssetsPlugin = require("optimize-css-assets-webpack-plugin")
|
||||
const CompressionPlugin = require("compression-webpack-plugin")
|
||||
|
||||
const config = {
|
||||
mode: 'production',
|
||||
|
@ -67,7 +68,8 @@ const config = {
|
|||
]
|
||||
},
|
||||
plugins: [
|
||||
new MiniCssExtractPlugin({})
|
||||
new MiniCssExtractPlugin({}),
|
||||
new CompressionPlugin({})
|
||||
]
|
||||
}
|
||||
|
||||
|
|
20
yarn.lock
20
yarn.lock
|
@ -1253,7 +1253,7 @@ bytes@3.0.0:
|
|||
version "3.0.0"
|
||||
resolved "https://registry.yarnpkg.com/bytes/-/bytes-3.0.0.tgz#d32815404d689699f85a4ea4fa8755dd13a96048"
|
||||
|
||||
cacache@^10.0.4:
|
||||
cacache@^10.0.1, cacache@^10.0.4:
|
||||
version "10.0.4"
|
||||
resolved "https://registry.yarnpkg.com/cacache/-/cacache-10.0.4.tgz#6452367999eff9d4188aefd9a14e9d7c6a263460"
|
||||
dependencies:
|
||||
|
@ -1613,6 +1613,16 @@ component-emitter@^1.2.1:
|
|||
version "1.2.1"
|
||||
resolved "https://registry.yarnpkg.com/component-emitter/-/component-emitter-1.2.1.tgz#137918d6d78283f7df7a6b7c5a63e140e69425e6"
|
||||
|
||||
compression-webpack-plugin@^1.1.11:
|
||||
version "1.1.11"
|
||||
resolved "https://registry.yarnpkg.com/compression-webpack-plugin/-/compression-webpack-plugin-1.1.11.tgz#8384c7a6ead1d2e2efb190bdfcdcf35878ed8266"
|
||||
dependencies:
|
||||
cacache "^10.0.1"
|
||||
find-cache-dir "^1.0.0"
|
||||
neo-async "^2.5.0"
|
||||
serialize-javascript "^1.4.0"
|
||||
webpack-sources "^1.0.1"
|
||||
|
||||
concat-map@0.0.1:
|
||||
version "0.0.1"
|
||||
resolved "https://registry.yarnpkg.com/concat-map/-/concat-map-0.0.1.tgz#d8a96bd77fd68df7793a73036a3ba0d5405d477b"
|
||||
|
@ -2283,6 +2293,12 @@ expand-tilde@^2.0.0, expand-tilde@^2.0.2:
|
|||
dependencies:
|
||||
homedir-polyfill "^1.0.1"
|
||||
|
||||
express-static-gzip@^0.3.2:
|
||||
version "0.3.2"
|
||||
resolved "https://registry.yarnpkg.com/express-static-gzip/-/express-static-gzip-0.3.2.tgz#89ede84547a5717de3146315f62dc996c071a88d"
|
||||
dependencies:
|
||||
serve-static "^1.12.3"
|
||||
|
||||
express@^4.13.4:
|
||||
version "4.16.3"
|
||||
resolved "https://registry.yarnpkg.com/express/-/express-4.16.3.tgz#6af8a502350db3246ecc4becf6b5a34d22f7ed53"
|
||||
|
@ -5753,7 +5769,7 @@ serialize-javascript@^1.4.0:
|
|||
version "1.5.0"
|
||||
resolved "https://registry.yarnpkg.com/serialize-javascript/-/serialize-javascript-1.5.0.tgz#1aa336162c88a890ddad5384baebc93a655161fe"
|
||||
|
||||
serve-static@1.13.2:
|
||||
serve-static@1.13.2, serve-static@^1.12.3:
|
||||
version "1.13.2"
|
||||
resolved "https://registry.yarnpkg.com/serve-static/-/serve-static-1.13.2.tgz#095e8472fd5b46237db50ce486a43f4b86c6cec1"
|
||||
dependencies:
|
||||
|
|
Loading…
Reference in New Issue