mirror of
https://github.com/nuxt/nuxt.git
synced 2024-11-29 00:52:01 +00:00
35 lines
880 B
JavaScript
35 lines
880 B
JavaScript
import path from 'path'
|
|
import { defu } from 'defu'
|
|
import { loadNuxtConfig as _loadNuxtConfig, getDefaultNuxtConfig } from '@nuxt/config'
|
|
|
|
export async function loadNuxtConfig (argv, configContext) {
|
|
const rootDir = path.resolve(argv._[0] || '.')
|
|
const configFile = argv['config-file']
|
|
|
|
// Load config
|
|
const options = await _loadNuxtConfig({
|
|
rootDir,
|
|
configFile,
|
|
configContext,
|
|
envConfig: {
|
|
dotenv: argv.dotenv === 'false' ? false : argv.dotenv,
|
|
env: argv.processenv ? process.env : {}
|
|
}
|
|
})
|
|
|
|
if (argv.spa === true) {
|
|
options.ssr = false
|
|
} else if (argv.universal === true) {
|
|
options.ssr = true
|
|
}
|
|
|
|
// Server options
|
|
options.server = defu({
|
|
port: argv.port || null,
|
|
host: argv.hostname || null,
|
|
socket: argv['unix-socket'] || null
|
|
}, options.server || {}, getDefaultNuxtConfig().server)
|
|
|
|
return options
|
|
}
|