Add performance option

This commit is contained in:
Sébastien Chopin 2017-02-21 17:39:29 +00:00
parent 10c4b1550f
commit 6cc1231eb2
3 changed files with 14 additions and 5 deletions

View File

@ -41,6 +41,10 @@ class Nuxt {
extendRoutes: null,
scrollBehavior: null
},
performance: {
gzip: true,
prefetch: true
},
build: {}
}
// Sanitization

View File

@ -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

View File

@ -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()