Skip to content

Commit

Permalink
fix: cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
NeOMakinG committed Feb 26, 2025
1 parent a93e78d commit fdae26c
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 59 deletions.
13 changes: 0 additions & 13 deletions vite.config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -45,10 +45,6 @@ for (const dirent of fs.readdirSync(publicPath, { withFileTypes: true })) {
}

export default defineConfig(({ mode }) => {
const env = loadEnv(mode, process.cwd(), '')

console.log(`Using environment variables for ${mode} mode`)

return {
plugins: [
react(),
Expand All @@ -67,15 +63,6 @@ export default defineConfig(({ mode }) => {
...Object.fromEntries(
Object.entries(publicFilesEnvVars).map(([key, value]) => [`process.env.${key}`, value]),
),
...Object.fromEntries(
Object.entries(env).map(([key, value]) => [
`import.meta.env.${key}`,
JSON.stringify(value),
]),
),
...Object.fromEntries(
Object.entries(env).map(([key, value]) => [`process.env.${key}`, JSON.stringify(value)]),
),
global: 'globalThis',
'global.Buffer': ['buffer', 'Buffer'],
},
Expand Down
17 changes: 2 additions & 15 deletions vitest-packages.config.ts
Original file line number Diff line number Diff line change
@@ -1,25 +1,12 @@
/// <reference types="vitest" />
import { defineConfig, loadEnv } from 'vite'
import { defineConfig } from 'vite'

// eslint-disable-next-line import/no-default-export
export default defineConfig(async ({ mode }) => {
export default defineConfig(async () => {
const tsconfigPaths = (await import('vite-tsconfig-paths')).default

const env = loadEnv(mode, process.cwd(), '')

return {
plugins: [tsconfigPaths()],
define: {
...Object.fromEntries(
Object.entries(env).map(([key, value]) => [
`import.meta.env.${key}`,
JSON.stringify(value),
]),
),
...Object.fromEntries(
Object.entries(env).map(([key, value]) => [`process.env.${key}`, JSON.stringify(value)]),
),
},
test: {
include: ['packages/**/*.test.ts', 'packages/**/*.test.tsx'],
environment: 'happy-dom',
Expand Down
17 changes: 2 additions & 15 deletions vitest-side-effects.config.ts
Original file line number Diff line number Diff line change
@@ -1,29 +1,16 @@
/// <reference types="vitest" />
import { defineConfig, loadEnv } from 'vite'
import { defineConfig } from 'vite'

// This is weird but it works, and it's the only way I've found to make these two tests for now.
// There is something related to environment isolation and side effects that is causing these tests to fail.
// They work when ran individually (i.e when re-running failed tests only) but not when ran as a suite with all other tests.
// So we make a separate config for these and run them as a separate suite.
// eslint-disable-next-line import/no-default-export
export default defineConfig(async ({ mode }) => {
export default defineConfig(async () => {
const tsconfigPaths = (await import('vite-tsconfig-paths')).default

const env = loadEnv(mode, process.cwd(), '')

return {
plugins: [tsconfigPaths()],
define: {
...Object.fromEntries(
Object.entries(env).map(([key, value]) => [
`import.meta.env.${key}`,
JSON.stringify(value),
]),
),
...Object.fromEntries(
Object.entries(env).map(([key, value]) => [`process.env.${key}`, JSON.stringify(value)]),
),
},
test: {
include: ['src/lib/poll/poll.test.ts', 'src/lib/cryptography/login.test.ts'],
environment: 'happy-dom',
Expand Down
18 changes: 2 additions & 16 deletions vitest-web.config.ts
Original file line number Diff line number Diff line change
@@ -1,26 +1,12 @@
/// <reference types="vitest" />
import { defineConfig, loadEnv } from 'vite'
import { defineConfig } from 'vite'

// eslint-disable-next-line import/no-default-export
export default defineConfig(async ({ mode }) => {
export default defineConfig(async () => {
const tsconfigPaths = (await import('vite-tsconfig-paths')).default

console.log('mode', mode)
const env = loadEnv(mode, process.cwd(), '')

return {
plugins: [tsconfigPaths()],
define: {
...Object.fromEntries(
Object.entries(env).map(([key, value]) => [
`import.meta.env.${key}`,
JSON.stringify(value),
]),
),
...Object.fromEntries(
Object.entries(env).map(([key, value]) => [`process.env.${key}`, JSON.stringify(value)]),
),
},
test: {
include: [
'src/**/*.test.ts',
Expand Down

0 comments on commit fdae26c

Please sign in to comment.