mirror of
https://github.com/nuxt/nuxt.git
synced 2024-11-11 16:43:55 +00:00
Add performance option
This commit is contained in:
parent
10c4b1550f
commit
6cc1231eb2
@ -41,6 +41,10 @@ class Nuxt {
|
||||
extendRoutes: null,
|
||||
scrollBehavior: null
|
||||
},
|
||||
performance: {
|
||||
gzip: true,
|
||||
prefetch: true
|
||||
},
|
||||
build: {}
|
||||
}
|
||||
// Sanitization
|
||||
|
@ -30,7 +30,8 @@ export function render (req, res) {
|
||||
// Call webpack middleware only in development
|
||||
yield self.webpackDevMiddleware(req, res)
|
||||
yield self.webpackHotMiddleware(req, res)
|
||||
} else {
|
||||
}
|
||||
if (!self.dev && self.options.performance.gzip === true) {
|
||||
yield self.gzipMiddleware(req, res)
|
||||
}
|
||||
// If base in req.url, remove it for the middleware and vue-router
|
||||
|
@ -61,13 +61,17 @@ export default function () {
|
||||
// Add defer to scripts
|
||||
new ScriptExtHtmlWebpackPlugin({
|
||||
defaultAttribute: 'defer'
|
||||
}),
|
||||
// Add prefetch code-splitted routes
|
||||
new PreloadWebpackPlugin({
|
||||
rel: 'prefetch'
|
||||
})
|
||||
])
|
||||
|
||||
if (this.options.performance.prefetch === true) {
|
||||
// Add prefetch code-splitted routes
|
||||
config.plugins.push(
|
||||
new PreloadWebpackPlugin({
|
||||
rel: 'prefetch'
|
||||
})
|
||||
)
|
||||
}
|
||||
// client bundle progress bar
|
||||
config.plugins.push(
|
||||
new ProgressBarPlugin()
|
||||
|
Loading…
Reference in New Issue
Block a user