mirror of
https://github.com/nuxt/nuxt.git
synced 2025-01-31 07:40:33 +00:00
update build
This commit is contained in:
parent
401930450c
commit
648033f077
@ -9,6 +9,7 @@ const { resolve } = require('path')
|
|||||||
|
|
||||||
const rootDir = resolve(process.argv.slice(2)[0] || '.')
|
const rootDir = resolve(process.argv.slice(2)[0] || '.')
|
||||||
const nuxtConfigFile = resolve(rootDir, 'nuxt.config.js')
|
const nuxtConfigFile = resolve(rootDir, 'nuxt.config.js')
|
||||||
|
|
||||||
let options = {}
|
let options = {}
|
||||||
if (fs.existsSync(nuxtConfigFile)) {
|
if (fs.existsSync(nuxtConfigFile)) {
|
||||||
options = require(nuxtConfigFile)
|
options = require(nuxtConfigFile)
|
||||||
@ -16,12 +17,12 @@ if (fs.existsSync(nuxtConfigFile)) {
|
|||||||
if (typeof options.rootDir !== 'string') {
|
if (typeof options.rootDir !== 'string') {
|
||||||
options.rootDir = rootDir
|
options.rootDir = rootDir
|
||||||
}
|
}
|
||||||
|
|
||||||
options.dev = false // Create production build when calling `nuxt build`
|
options.dev = false // Create production build when calling `nuxt build`
|
||||||
|
|
||||||
console.log('[nuxt] Building...')
|
console.log('[nuxt] Building...')
|
||||||
new Nuxt(options)
|
const nuxt = new Nuxt(options)
|
||||||
.then((nuxt) => {
|
nuxt.build()
|
||||||
|
.then(() => {
|
||||||
console.log('[nuxt] Building done')
|
console.log('[nuxt] Building done')
|
||||||
})
|
})
|
||||||
.catch((err) => {
|
.catch((err) => {
|
||||||
|
@ -70,26 +70,24 @@ const defaultsPostcss = [
|
|||||||
})
|
})
|
||||||
]
|
]
|
||||||
|
|
||||||
module.exports = function * () {
|
exports.options = function () {
|
||||||
// Defaults build options
|
// Defaults build options
|
||||||
let extraDefaults = {}
|
let extraDefaults = {}
|
||||||
if (this.options.build && !Array.isArray(this.options.build.loaders)) extraDefaults.loaders = defaultsLoaders
|
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
|
if (this.options.build && !Array.isArray(this.options.build.postcss)) extraDefaults.postcss = defaultsPostcss
|
||||||
this.options.build = _.defaultsDeep(this.options.build, defaults, extraDefaults)
|
this.options.build = _.defaultsDeep(this.options.build, defaults, extraDefaults)
|
||||||
if (!this.options._build && !this.options._renderer) {
|
// Production, create server-renderer
|
||||||
return Promise.resolve()
|
if (!this.dev) {
|
||||||
}
|
|
||||||
if (!this.options._build) {
|
|
||||||
const serverConfig = getWebpackServerConfig.call(this)
|
const serverConfig = getWebpackServerConfig.call(this)
|
||||||
const bundlePath = join(serverConfig.output.path, serverConfig.output.filename)
|
const bundlePath = join(serverConfig.output.path, serverConfig.output.filename)
|
||||||
if (!fs.existsSync(bundlePath)) {
|
if (fs.existsSync(bundlePath)) {
|
||||||
console.error('> No build files found, please run `nuxt build` before launching `nuxt start`')
|
const bundle = fs.readFileSync(bundlePath, 'utf8')
|
||||||
process.exit(1)
|
createRenderer.call(this, bundle)
|
||||||
}
|
}
|
||||||
const bundle = yield readFile(bundlePath, 'utf8')
|
|
||||||
createRenderer.call(this, bundle)
|
|
||||||
return Promise.resolve()
|
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
exports.build = function * () {
|
||||||
/*
|
/*
|
||||||
** Check if pages dir exists and warn if not
|
** Check if pages dir exists and warn if not
|
||||||
*/
|
*/
|
||||||
@ -135,6 +133,7 @@ module.exports = function * () {
|
|||||||
webpackRunServer.call(this)
|
webpackRunServer.call(this)
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
return this
|
||||||
}
|
}
|
||||||
|
|
||||||
function * generateRoutesAndFiles () {
|
function * generateRoutesAndFiles () {
|
||||||
|
Loading…
Reference in New Issue
Block a user