mirror of
https://github.com/nuxt/nuxt.git
synced 2024-11-11 08:33:53 +00:00
Add Server class in nuxt
This commit is contained in:
parent
19e7e6f6cf
commit
4aa600e57a
@ -7,7 +7,6 @@ var _ = require('lodash')
|
|||||||
var debug = require('debug')('nuxt:build')
|
var debug = require('debug')('nuxt:build')
|
||||||
var fs = require('fs')
|
var fs = require('fs')
|
||||||
var Nuxt = require('../')
|
var Nuxt = require('../')
|
||||||
var Server = require('../lib/server')
|
|
||||||
var chokidar = require('chokidar')
|
var chokidar = require('chokidar')
|
||||||
var resolve = require('path').resolve
|
var resolve = require('path').resolve
|
||||||
|
|
||||||
@ -26,7 +25,7 @@ options.dev = true // Add hot reloading and watching changes
|
|||||||
var nuxt = new Nuxt(options)
|
var nuxt = new Nuxt(options)
|
||||||
nuxt.build()
|
nuxt.build()
|
||||||
.then(() => {
|
.then(() => {
|
||||||
var server = new Server(nuxt)
|
var server = new nuxt.Server(nuxt)
|
||||||
.listen(process.env.PORT || process.env.npm_package_config_nuxt_port, process.env.HOST || process.env.npm_package_config_nuxt_host)
|
.listen(process.env.PORT || process.env.npm_package_config_nuxt_port, process.env.HOST || process.env.npm_package_config_nuxt_host)
|
||||||
listenOnConfigChanges(nuxt, server)
|
listenOnConfigChanges(nuxt, server)
|
||||||
})
|
})
|
||||||
|
@ -2,7 +2,6 @@
|
|||||||
|
|
||||||
var fs = require('fs')
|
var fs = require('fs')
|
||||||
var Nuxt = require('../')
|
var Nuxt = require('../')
|
||||||
var Server = require('../lib/server')
|
|
||||||
var resolve = require('path').resolve
|
var resolve = require('path').resolve
|
||||||
|
|
||||||
var rootDir = resolve(process.argv.slice(2)[0] || '.')
|
var rootDir = resolve(process.argv.slice(2)[0] || '.')
|
||||||
@ -19,7 +18,7 @@ options.dev = false // Force production mode (no webpack middlewares called)
|
|||||||
|
|
||||||
var nuxt = new Nuxt(options)
|
var nuxt = new Nuxt(options)
|
||||||
|
|
||||||
new Server(nuxt)
|
new nuxt.Server(nuxt)
|
||||||
.listen(
|
.listen(
|
||||||
process.env.PORT || process.env.npm_package_config_nuxt_port,
|
process.env.PORT || process.env.npm_package_config_nuxt_port,
|
||||||
process.env.HOST || process.env.npm_package_config_nuxt_host
|
process.env.HOST || process.env.npm_package_config_nuxt_host
|
||||||
|
@ -6,6 +6,7 @@ const fs = require('fs-extra')
|
|||||||
const pify = require('pify')
|
const pify = require('pify')
|
||||||
const ansiHTML = require('ansi-html')
|
const ansiHTML = require('ansi-html')
|
||||||
const serialize = require('serialize-javascript')
|
const serialize = require('serialize-javascript')
|
||||||
|
const Server = require('./server')
|
||||||
const build = require('./build')
|
const build = require('./build')
|
||||||
const render = require('./render')
|
const render = require('./render')
|
||||||
const generate = require('./generate')
|
const generate = require('./generate')
|
||||||
@ -70,6 +71,8 @@ class Nuxt {
|
|||||||
// For serving .nuxt/dist/ files
|
// For serving .nuxt/dist/ files
|
||||||
this._nuxtRegexp = /^\/_nuxt\//
|
this._nuxtRegexp = /^\/_nuxt\//
|
||||||
this.serveStaticNuxt = pify(serveStatic(resolve(this.dir, '.nuxt', 'dist')))
|
this.serveStaticNuxt = pify(serveStatic(resolve(this.dir, '.nuxt', 'dist')))
|
||||||
|
// Add this.Server Class
|
||||||
|
this.Server = Server
|
||||||
// Add this.build
|
// Add this.build
|
||||||
build.options.call(this) // Add build options
|
build.options.call(this) // Add build options
|
||||||
this.build = () => co(build.build.bind(this))
|
this.build = () => co(build.build.bind(this))
|
||||||
|
Loading…
Reference in New Issue
Block a user