From 7b3c62739c436454b35e93878d0d51037c64dd93 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Chopin?= Date: Tue, 21 Feb 2017 11:31:47 +0000 Subject: [PATCH] Remove conditional nuxtStatic middleware --- lib/build.js | 9 ++------- lib/nuxt.js | 1 - lib/render.js | 2 +- 3 files changed, 3 insertions(+), 9 deletions(-) diff --git a/lib/build.js b/lib/build.js index 74f86bc6e7..fea707e5a2 100644 --- a/lib/build.js +++ b/lib/build.js @@ -91,13 +91,8 @@ export function options () { if (this.options.build && !Array.isArray(this.options.build.loaders)) extraDefaults.loaders = defaultsLoaders if (this.options.build && !Array.isArray(this.options.build.postcss)) extraDefaults.postcss = defaultsPostcss this.options.build = _.defaultsDeep(this.options.build, defaults, extraDefaults) - if (this.options.build.publicPath.indexOf('http') === 0) { - // activate only in production mode - if (this.dev) { - this.options.build.publicPath = defaults.publicPath - } else { - this.options.nuxtStatic = false - } + if (this.options.build.publicPath.indexOf('http') === 0 && this.dev) { + this.options.build.publicPath = defaults.publicPath } // Production, create server-renderer if (!this.dev) { diff --git a/lib/nuxt.js b/lib/nuxt.js index 72f1a32ab9..b055946ffe 100644 --- a/lib/nuxt.js +++ b/lib/nuxt.js @@ -78,7 +78,6 @@ class Nuxt { // For serving static/ files to / this.serveStatic = pify(serveStatic(resolve(this.srcDir, 'static'))) // For serving .nuxt/dist/ files (only when build.publicPath is not an URL) - this.options.nuxtStatic = true this.serveStaticNuxt = pify(serveStatic(resolve(this.dir, '.nuxt', 'dist'))) // Add this.Server Class this.Server = Server diff --git a/lib/render.js b/lib/render.js index 04158e5d3c..fabc1da1ec 100644 --- a/lib/render.js +++ b/lib/render.js @@ -36,7 +36,7 @@ export function render (req, res) { // Serve static/ files yield self.serveStatic(req, res) // Serve .nuxt/dist/ files (only for production) - if (!self.dev && self.options.nuxtStatic && req.url.indexOf(self.options.build.publicPath) === 0) { + if (!self.dev && req.url.indexOf(self.options.build.publicPath) === 0) { const url = req.url req.url = req.url.replace(self.options.build.publicPath, '/') yield self.serveStaticNuxt(req, res)