1
0
Fork 1
mirror of https://github.com/elk-zone/elk.git synced 2024-11-19 15:29:59 +00:00
elk/modules/tauri/index.ts
三咲智子 5f7f7573c6
fix(tauri): upgrade target browser version
used top-level await, only Safari > 15 supports it
2023-01-07 04:00:19 +08:00

41 lines
1.1 KiB
TypeScript

import { addImports, addPlugin, createResolver, defineNuxtModule, useNuxt } from '@nuxt/kit'
export default defineNuxtModule({
meta: {
name: 'tauri',
},
setup() {
const nuxt = useNuxt()
const { resolve } = createResolver(import.meta.url)
if (!process.env.TAURI_PLATFORM)
return
if (nuxt.options.dev)
nuxt.options.ssr = false
nuxt.options.alias = {
...nuxt.options.alias,
'unstorage/drivers/fs': 'unenv/runtime/mock/proxy',
'unstorage/drivers/cloudflare-kv-http': 'unenv/runtime/mock/proxy',
'node:events': 'unenv/runtime/node/events/index',
}
nuxt.hook('vite:extend', ({ config }) => {
config.build!.target = ['chrome100', 'safari15']
config.envPrefix = [...config.envPrefix || [], 'VITE_', 'TAURI_']
})
// prevent creation of server routes
nuxt.hook('nitro:config', (config) => {
config.srcDir = './_nonexistent'
config.scanDirs = []
})
addImports({ name: 'useStorage', from: resolve('./runtime/storage') })
addPlugin(resolve('./runtime/logging.client'))
addPlugin(resolve('./runtime/nitro.client'))
},
})