mtcute/.config/vite.browser.ts

56 lines
1.6 KiB
TypeScript
Raw Normal View History

2023-11-29 20:31:18 +03:00
/// <reference types="vitest" />
2024-08-12 05:23:26 +03:00
import { mergeConfig } from 'vite'
import { nodePolyfills } from 'vite-plugin-node-polyfills'
2023-11-29 20:31:18 +03:00
import { fixupCjs } from './vite-utils/fixup-cjs'
import baseConfig from './vite.js'
2023-11-29 20:31:18 +03:00
2024-08-12 05:23:26 +03:00
export default mergeConfig(baseConfig, {
2023-11-29 20:31:18 +03:00
test: {
browser: {
enabled: true,
name: 'chromium',
provider: 'playwright',
slowHijackESM: false,
},
fakeTimers: {
toFake: ['setTimeout', 'clearTimeout', 'setInterval', 'clearInterval', 'Date'],
2023-11-29 20:31:18 +03:00
},
2023-12-02 19:24:35 +03:00
retry: process.env.CI ? 3 : 0,
isolate: false,
fileParallelism: false, // leads to ERR_INSUFFICIENT_RESOURCES
2023-11-29 20:31:18 +03:00
// for whatever reason using exclude-s makes the vite never start the browser, so we use skip-s instead.
// exclude: [
// './packages/crypto-node/**',
// './packages/node/**',
// ],
},
plugins: [
fixupCjs(),
nodePolyfills({
include: ['stream', 'path', 'zlib', 'util', 'events'],
globals: {
Buffer: false,
global: false,
process: false,
},
}),
2023-11-29 20:31:18 +03:00
],
2024-08-12 05:23:26 +03:00
build: {
rollupOptions: {
2024-08-21 11:05:07 +03:00
external: ['bun:sqlite', '@jsr/db__sqlite'],
},
2024-08-12 05:23:26 +03:00
},
2023-11-29 20:31:18 +03:00
define: {
'import.meta.env.TEST_ENV': '"browser"',
},
2024-08-21 11:05:07 +03:00
optimizeDeps: {
esbuildOptions: {
// for WHATEVER REASON browserify-zlib uses `global` and it dies in browser lol
define: {
global: 'globalThis',
},
},
},
2024-08-12 05:23:26 +03:00
})