2019-04-11 10:04:21 +00:00
|
|
|
import path from 'path'
|
2020-12-22 17:07:50 +00:00
|
|
|
import defu from 'defu'
|
2020-01-19 08:36:06 +00:00
|
|
|
import { loadNuxtConfig as _loadNuxtConfig, getDefaultNuxtConfig } from '@nuxt/config'
|
2019-04-11 10:04:21 +00:00
|
|
|
|
2020-01-19 08:36:06 +00:00
|
|
|
export async function loadNuxtConfig (argv, configContext) {
|
2019-04-11 10:04:21 +00:00
|
|
|
const rootDir = path.resolve(argv._[0] || '.')
|
2020-01-19 08:36:06 +00:00
|
|
|
const configFile = argv['config-file']
|
2019-04-11 10:04:21 +00:00
|
|
|
|
2020-01-19 08:36:06 +00:00
|
|
|
// Load config
|
|
|
|
const options = await _loadNuxtConfig({
|
|
|
|
rootDir,
|
|
|
|
configFile,
|
2020-05-18 08:21:15 +00:00
|
|
|
configContext,
|
|
|
|
envConfig: {
|
|
|
|
dotenv: argv.dotenv === 'false' ? false : argv.dotenv,
|
|
|
|
env: argv.processenv ? process.env : {}
|
|
|
|
}
|
2020-01-19 08:36:06 +00:00
|
|
|
})
|
2019-04-11 10:04:21 +00:00
|
|
|
|
2020-10-08 14:30:02 +00:00
|
|
|
if (argv.spa === true) {
|
|
|
|
options.ssr = false
|
|
|
|
} else if (argv.universal === true) {
|
|
|
|
options.ssr = true
|
|
|
|
}
|
2019-04-11 10:04:21 +00:00
|
|
|
|
|
|
|
// Server options
|
2020-12-22 17:07:50 +00:00
|
|
|
options.server = defu({
|
|
|
|
port: argv.port || null,
|
|
|
|
host: argv.hostname || null,
|
|
|
|
socket: argv['unix-socket'] || null
|
2019-04-11 10:04:21 +00:00
|
|
|
}, options.server || {}, getDefaultNuxtConfig().server)
|
|
|
|
|
|
|
|
return options
|
|
|
|
}
|