mirror of
https://github.com/nuxt/nuxt.git
synced 2024-11-11 08:33:53 +00:00
add gzip configuration
This commit is contained in:
parent
77439223cf
commit
c9784651e9
10
lib/nuxt.js
10
lib/nuxt.js
@ -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
|
||||
|
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user