mirror of
https://github.com/nuxt/nuxt.git
synced 2024-11-27 08:02:01 +00:00
parent
e2ab1b4896
commit
14fe6792ae
@ -103,10 +103,16 @@ export default class VueRenderer {
|
||||
await this.loadResources(fs)
|
||||
|
||||
// Verify
|
||||
if (!this.isReady && this.context.options._start) {
|
||||
if (this.context.options._start) {
|
||||
if (!this.isReady) {
|
||||
throw new Error(
|
||||
'No build files found. Use either `nuxt build` or `builder.build()` or start nuxt in development mode.'
|
||||
)
|
||||
} else if (this.context.options.modern && !this.context.resources.modernManifest) {
|
||||
throw new Error(
|
||||
'No modern build files found. Use either `nuxt build --modern` or `modern` option to build modern files.'
|
||||
)
|
||||
}
|
||||
}
|
||||
} else {
|
||||
// Development: Listen on build:resources hook
|
||||
|
@ -1,9 +1,15 @@
|
||||
import path from 'path'
|
||||
import consola from 'consola'
|
||||
import { Nuxt } from '../utils'
|
||||
|
||||
const NO_BUILD_MSG = 'No build files found. Use either `nuxt build` or `builder.build()` or start nuxt in development mode.'
|
||||
const NO_MODERN_BUILD_MSG = 'No modern build files found. Use either `nuxt build --modern` or `modern` option to build modern files.'
|
||||
|
||||
describe('renderer', () => {
|
||||
afterEach(() => {
|
||||
consola.fatal.mockClear()
|
||||
})
|
||||
|
||||
test('detect no-build (Universal)', async () => {
|
||||
const nuxt = new Nuxt({
|
||||
_start: true,
|
||||
@ -27,4 +33,16 @@ describe('renderer', () => {
|
||||
await expect(nuxt.renderer.renderer.isReady).toBe(false)
|
||||
expect(consola.fatal).toHaveBeenCalledWith(new Error(NO_BUILD_MSG))
|
||||
})
|
||||
test('detect no-modern-build', async () => {
|
||||
const nuxt = new Nuxt({
|
||||
_start: true,
|
||||
mode: 'universal',
|
||||
modern: 'client',
|
||||
dev: false,
|
||||
buildDir: path.resolve(__dirname, '..', 'fixtures', 'empty', '.nuxt')
|
||||
})
|
||||
await nuxt.ready()
|
||||
await expect(nuxt.renderer.renderer.isReady).toBe(true)
|
||||
expect(consola.fatal).toHaveBeenCalledWith(new Error(NO_MODERN_BUILD_MSG))
|
||||
})
|
||||
})
|
||||
|
Loading…
Reference in New Issue
Block a user