add gzip configuration

This commit is contained in:
Alexandre Chopin 2017-03-25 12:57:34 +01:00
parent 77439223cf
commit c9784651e9
2 changed files with 6 additions and 6 deletions

View File

@ -41,7 +41,9 @@ class Nuxt {
scrollBehavior: null
},
performance: {
gzip: true,
gzip: {
threshold: 0
},
prefetch: true
},
build: {}
@ -73,10 +75,8 @@ class Nuxt {
maxAge: (this.dev ? 0 : '1y') // 1 year in production
}))
// gzip for production
if (!this.dev) {
this.gzipMiddleware = pify(compression({
threshold: 0
}))
if (!this.dev && this.options.performance.gzip) {
this.gzipMiddleware = pify(compression(this.options.performance.gzip))
}
// Add this.Server Class
this.Server = Server

View File

@ -31,7 +31,7 @@ export function render (req, res) {
yield self.webpackDevMiddleware(req, res)
yield self.webpackHotMiddleware(req, res)
}
if (!self.dev && self.options.performance.gzip === true) {
if (!self.dev && self.options.performance.gzip) {
yield self.gzipMiddleware(req, res)
}
// If base in req.url, remove it for the middleware and vue-router