Remove conditional nuxtStatic middleware

This commit is contained in:
Sébastien Chopin 2017-02-21 11:31:47 +00:00
parent 9a2767ac90
commit 7b3c62739c
3 changed files with 3 additions and 9 deletions

View File

@ -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) {
if (this.options.build.publicPath.indexOf('http') === 0 && this.dev) {
this.options.build.publicPath = defaults.publicPath
} else {
this.options.nuxtStatic = false
}
}
// Production, create server-renderer
if (!this.dev) {

View File

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

View File

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