mirror of
https://github.com/tauri-apps/tauri.git
synced 2024-12-18 16:11:38 +03:00
878421beb7
Co-authored-by: Ben Wishovich <ben@benw.is>
46 lines
901 B
TypeScript
46 lines
901 B
TypeScript
import { resolve } from 'path'
|
|
import { sveltekit } from '@sveltejs/kit/vite'
|
|
import wasm from 'vite-plugin-wasm'
|
|
import topLevelAwait from 'vite-plugin-top-level-await'
|
|
import { viteStaticCopy } from 'vite-plugin-static-copy'
|
|
import type { UserConfig } from 'vite'
|
|
|
|
const TARGET = process.env.TARGET
|
|
|
|
const plugins = [sveltekit()]
|
|
|
|
if (TARGET === 'web') {
|
|
plugins.push(wasm())
|
|
plugins.push(topLevelAwait())
|
|
plugins.push(
|
|
viteStaticCopy({
|
|
targets: [
|
|
{
|
|
src: 'core/wasm/pkg/wasm_bg.wasm',
|
|
dest: 'wasm'
|
|
}
|
|
]
|
|
})
|
|
)
|
|
}
|
|
|
|
const config: UserConfig = {
|
|
server: {
|
|
fs: {
|
|
// Allow serving the wasm file from this folder.
|
|
allow: ['.']
|
|
}
|
|
},
|
|
plugins,
|
|
resolve: {
|
|
alias: {
|
|
$api:
|
|
TARGET === 'tauri'
|
|
? resolve('./src/api/desktop')
|
|
: resolve('./src/api/web')
|
|
}
|
|
}
|
|
}
|
|
|
|
export default config
|