mirror of
https://github.com/nuxt/nuxt.git
synced 2024-11-30 09:27:13 +00:00
Remove conditional nuxtStatic middleware
This commit is contained in:
parent
9a2767ac90
commit
7b3c62739c
@ -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) {
|
||||
|
@ -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
|
||||
|
@ -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)
|
||||
|
Loading…
Reference in New Issue
Block a user