fix: nitro config

This commit is contained in:
Anthony Fu 2023-01-08 14:27:29 +01:00
parent b7b6f0d1ca
commit fd2c433644

View file

@ -1,4 +1,5 @@
import { createResolver, defineNuxtModule } from '@nuxt/kit' import { createResolver, defineNuxtModule } from '@nuxt/kit'
import { isCI } from 'std-env'
import { getEnv, version } from '../config/env' import { getEnv, version } from '../config/env'
import type { BuildInfo } from '~/types' import type { BuildInfo } from '~/types'
@ -21,10 +22,12 @@ export default defineNuxtModule({
nuxt.options.runtimeConfig.public.env = env nuxt.options.runtimeConfig.public.env = env
nuxt.options.runtimeConfig.public.buildInfo = buildInfo nuxt.options.runtimeConfig.public.buildInfo = buildInfo
nuxt.options.nitro.publicAssets ||= nuxt.options.nitro.publicAssets || [] nuxt.hook('nitro:config', (config) => {
if (env === 'canary' || env === 'preview') config.publicAssets = config.publicAssets || []
nuxt.options.nitro.publicAssets.push({ dir: resolve('../public-staging') }) if (env === 'dev')
else if (env === 'dev') config.publicAssets.push({ dir: resolve('../public-dev') })
nuxt.options.nitro.publicAssets.push({ dir: resolve('../public-dev') }) else if (env === 'canary' || env === 'preview' || !isCI)
config.publicAssets.push({ dir: resolve('../public-staging') })
})
}, },
}) })