diff --git a/lib/nuxt.js b/lib/nuxt.js index 4ae4be41a2..ff97870b41 100644 --- a/lib/nuxt.js +++ b/lib/nuxt.js @@ -41,6 +41,10 @@ class Nuxt { extendRoutes: null, scrollBehavior: null }, + performance: { + gzip: true, + prefetch: true + }, build: {} } // Sanitization diff --git a/lib/render.js b/lib/render.js index e1db3d9fbd..105b3dc352 100644 --- a/lib/render.js +++ b/lib/render.js @@ -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 diff --git a/lib/webpack/client.config.js b/lib/webpack/client.config.js index 2023e5b0fa..dffff99230 100644 --- a/lib/webpack/client.config.js +++ b/lib/webpack/client.config.js @@ -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()