perf!: allow tree-shaking unstorage drivers (#1516)

* perf: allow tree-shaking unstorage drivers

* fix: allow overriding fsBase at runtime

* fix: remove `fsBase` export
This commit is contained in:
Daniel Roe 2023-01-29 07:52:01 -08:00 committed by GitHub
parent 415d36ce32
commit fa44fae991
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 24 additions and 8 deletions

View file

@ -1,4 +1,4 @@
import { createResolver } from '@nuxt/kit'
import { createResolver, useNuxt } from '@nuxt/kit'
import Inspect from 'vite-plugin-inspect'
import { isCI, isDevelopment, isWindows } from 'std-env'
import { isPreview } from './config/env'
@ -86,6 +86,11 @@ export default defineNuxtConfig({
'postcss-nested': {},
},
},
appConfig: {
storage: {
driver: process.env.NUXT_STORAGE_DRIVER ?? (isCI ? 'cloudflare' : 'fs'),
},
},
runtimeConfig: {
adminKey: '',
cloudflare: {
@ -102,8 +107,7 @@ export default defineNuxtConfig({
defaultServer: 'm.webtoo.ls',
},
storage: {
driver: isCI ? 'cloudflare' : 'fs',
fsBase: 'node_modules/.cache/servers',
fsBase: 'node_modules/.cache/app',
},
},
routeRules: {
@ -126,6 +130,13 @@ export default defineNuxtConfig({
ignore: ['/settings'],
},
},
hooks: {
'nitro:config': function (config) {
const nuxt = useNuxt()
config.virtual = config.virtual || {}
config.virtual['#storage-config'] = `export const driver = ${JSON.stringify(nuxt.options.appConfig.storage.driver)}`
},
},
app: {
keepalive: true,
head: {