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