2018-10-24 13:53:34 +00:00
|
|
|
|
|
|
|
import path from 'path'
|
|
|
|
import { defaultsDeep } from 'lodash'
|
2019-01-16 17:53:14 +00:00
|
|
|
import { version as coreVersion } from '../../packages/core/package.json'
|
2018-10-24 13:53:34 +00:00
|
|
|
|
|
|
|
export { Nuxt } from '../../packages/core/src/index'
|
2018-10-24 16:55:18 +00:00
|
|
|
export { Builder } from '../../packages/builder/src/index'
|
|
|
|
export { Generator } from '../../packages/generator/src/index'
|
2018-10-25 11:22:31 +00:00
|
|
|
export { BundleBuilder } from '../../packages/webpack/src/index'
|
2018-12-22 21:05:13 +00:00
|
|
|
export * from '../../packages/utils/src/index'
|
2018-10-24 13:53:34 +00:00
|
|
|
|
2019-01-16 17:53:14 +00:00
|
|
|
export const version = `v${coreVersion}`
|
|
|
|
|
2018-10-24 13:53:34 +00:00
|
|
|
export const loadFixture = async function (fixture, overrides) {
|
|
|
|
const rootDir = path.resolve(__dirname, '..', 'fixtures', fixture)
|
2019-01-20 18:43:27 +00:00
|
|
|
let config = {}
|
|
|
|
|
2019-01-20 18:50:01 +00:00
|
|
|
try {
|
2019-01-20 18:53:27 +00:00
|
|
|
config = await import(`../fixtures/${fixture}/nuxt.config`)
|
2019-01-20 18:50:01 +00:00
|
|
|
config = config.default || config
|
|
|
|
} catch (e) {
|
|
|
|
// Ignore MODULE_NOT_FOUND
|
|
|
|
if (e.code !== 'MODULE_NOT_FOUND') {
|
|
|
|
throw e
|
2019-01-20 18:43:27 +00:00
|
|
|
}
|
|
|
|
}
|
2018-10-24 13:53:34 +00:00
|
|
|
|
|
|
|
if (typeof config === 'function') {
|
|
|
|
config = await config()
|
|
|
|
}
|
|
|
|
|
|
|
|
config.rootDir = rootDir
|
|
|
|
config.dev = false
|
|
|
|
config.test = true
|
|
|
|
|
2019-08-24 14:13:03 +00:00
|
|
|
// disable terser to speed-up fixture builds
|
|
|
|
if (config.build) {
|
|
|
|
if (!config.build.terser) {
|
|
|
|
config.build.terser = false
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
config.build = { terser: false }
|
|
|
|
}
|
|
|
|
|
2018-10-24 13:53:34 +00:00
|
|
|
return defaultsDeep({}, overrides, config)
|
2018-10-24 14:00:50 +00:00
|
|
|
}
|