mirror of
https://github.com/nuxt/nuxt.git
synced 2024-11-13 09:33:54 +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
|
scrollBehavior: null
|
||||||
},
|
},
|
||||||
performance: {
|
performance: {
|
||||||
gzip: true,
|
gzip: {
|
||||||
|
threshold: 0
|
||||||
|
},
|
||||||
prefetch: true
|
prefetch: true
|
||||||
},
|
},
|
||||||
build: {}
|
build: {}
|
||||||
@ -73,10 +75,8 @@ class Nuxt {
|
|||||||
maxAge: (this.dev ? 0 : '1y') // 1 year in production
|
maxAge: (this.dev ? 0 : '1y') // 1 year in production
|
||||||
}))
|
}))
|
||||||
// gzip for production
|
// gzip for production
|
||||||
if (!this.dev) {
|
if (!this.dev && this.options.performance.gzip) {
|
||||||
this.gzipMiddleware = pify(compression({
|
this.gzipMiddleware = pify(compression(this.options.performance.gzip))
|
||||||
threshold: 0
|
|
||||||
}))
|
|
||||||
}
|
}
|
||||||
// Add this.Server Class
|
// Add this.Server Class
|
||||||
this.Server = Server
|
this.Server = Server
|
||||||
|
@ -31,7 +31,7 @@ export function render (req, res) {
|
|||||||
yield self.webpackDevMiddleware(req, res)
|
yield self.webpackDevMiddleware(req, res)
|
||||||
yield self.webpackHotMiddleware(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)
|
yield self.gzipMiddleware(req, res)
|
||||||
}
|
}
|
||||||
// If base in req.url, remove it for the middleware and vue-router
|
// If base in req.url, remove it for the middleware and vue-router
|
||||||
|
Loading…
Reference in New Issue
Block a user