Nuxt/test/utils/nuxt.js

35 lines
1.0 KiB
JavaScript
Raw Normal View History

2018-10-24 13:53:34 +00:00
import path from 'path'
import { defaultsDeep } from 'lodash'
import { version as coreVersion } from '../../packages/core/package.json'
import { loadNuxtConfig } from '../../packages/config/src/index'
2018-10-24 13:53:34 +00:00
export { Nuxt } from '../../packages/core/src/index'
export { Builder } from '../../packages/builder/src/index'
export { Generator } from '../../packages/generator/src/index'
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
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)
const config = await loadNuxtConfig({
rootDir,
configOverrides: {
dev: false,
test: true
}
})
2018-10-24 13:53:34 +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
}