2023-01-13 11:46:07 +03:00
|
|
|
import { rm } from 'fs/promises'
|
2022-12-22 05:12:37 +03:00
|
|
|
import { addImports, addPlugin, createResolver, defineNuxtModule, useNuxt } from '@nuxt/kit'
|
2022-12-21 02:56:57 +03:00
|
|
|
|
|
|
|
export default defineNuxtModule({
|
|
|
|
meta: {
|
|
|
|
name: 'tauri',
|
|
|
|
},
|
|
|
|
setup() {
|
|
|
|
const nuxt = useNuxt()
|
|
|
|
const { resolve } = createResolver(import.meta.url)
|
|
|
|
|
|
|
|
if (!process.env.TAURI_PLATFORM)
|
|
|
|
return
|
|
|
|
|
2022-12-22 05:12:37 +03:00
|
|
|
if (nuxt.options.dev)
|
|
|
|
nuxt.options.ssr = false
|
|
|
|
|
2023-01-13 11:46:07 +03:00
|
|
|
nuxt.options.pwa.disable = true
|
|
|
|
nuxt.options.sourcemap.client = false
|
|
|
|
|
2022-12-22 05:12:37 +03:00
|
|
|
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',
|
2023-01-29 17:18:27 +03:00
|
|
|
'#build-info': resolve('./runtime/build-info'),
|
2022-12-22 05:12:37 +03:00
|
|
|
}
|
|
|
|
|
2022-12-21 02:56:57 +03:00
|
|
|
nuxt.hook('vite:extend', ({ config }) => {
|
2023-01-06 22:59:56 +03:00
|
|
|
config.build!.target = ['chrome100', 'safari15']
|
2022-12-21 02:56:57 +03:00
|
|
|
config.envPrefix = [...config.envPrefix || [], 'VITE_', 'TAURI_']
|
|
|
|
})
|
|
|
|
|
2022-12-22 05:12:37 +03:00
|
|
|
// prevent creation of server routes
|
|
|
|
nuxt.hook('nitro:config', (config) => {
|
|
|
|
config.srcDir = './_nonexistent'
|
|
|
|
config.scanDirs = []
|
|
|
|
})
|
|
|
|
|
|
|
|
addImports({ name: 'useStorage', from: resolve('./runtime/storage') })
|
|
|
|
|
2022-12-21 02:56:57 +03:00
|
|
|
addPlugin(resolve('./runtime/logging.client'))
|
2022-12-22 05:12:37 +03:00
|
|
|
addPlugin(resolve('./runtime/nitro.client'))
|
2023-01-13 11:46:07 +03:00
|
|
|
|
|
|
|
// cleanup files copied from the public folder that we don't need
|
|
|
|
nuxt.hook('close', async () => {
|
|
|
|
await rm('.output/public/_redirects')
|
|
|
|
await rm('.output/public/apple-touch-icon.png')
|
|
|
|
await rm('.output/public/elk-og.png')
|
|
|
|
await rm('.output/public/favicon.ico')
|
|
|
|
await rm('.output/public/pwa-192x192.png')
|
|
|
|
await rm('.output/public/pwa-512x512.png')
|
|
|
|
await rm('.output/public/robots.txt')
|
|
|
|
})
|
2022-12-21 02:56:57 +03:00
|
|
|
},
|
|
|
|
})
|