mirror of
https://github.com/nuxt/nuxt.git
synced 2025-01-30 15:22:39 +00:00
Add performance option
This commit is contained in:
parent
10c4b1550f
commit
6cc1231eb2
@ -41,6 +41,10 @@ class Nuxt {
|
|||||||
extendRoutes: null,
|
extendRoutes: null,
|
||||||
scrollBehavior: null
|
scrollBehavior: null
|
||||||
},
|
},
|
||||||
|
performance: {
|
||||||
|
gzip: true,
|
||||||
|
prefetch: true
|
||||||
|
},
|
||||||
build: {}
|
build: {}
|
||||||
}
|
}
|
||||||
// Sanitization
|
// Sanitization
|
||||||
|
@ -30,7 +30,8 @@ export function render (req, res) {
|
|||||||
// Call webpack middleware only in development
|
// Call webpack middleware only in development
|
||||||
yield self.webpackDevMiddleware(req, res)
|
yield self.webpackDevMiddleware(req, res)
|
||||||
yield self.webpackHotMiddleware(req, res)
|
yield self.webpackHotMiddleware(req, res)
|
||||||
} else {
|
}
|
||||||
|
if (!self.dev && self.options.performance.gzip === true) {
|
||||||
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
|
||||||
|
@ -61,13 +61,17 @@ export default function () {
|
|||||||
// Add defer to scripts
|
// Add defer to scripts
|
||||||
new ScriptExtHtmlWebpackPlugin({
|
new ScriptExtHtmlWebpackPlugin({
|
||||||
defaultAttribute: 'defer'
|
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
|
// client bundle progress bar
|
||||||
config.plugins.push(
|
config.plugins.push(
|
||||||
new ProgressBarPlugin()
|
new ProgressBarPlugin()
|
||||||
|
Loading…
Reference in New Issue
Block a user