Skip to content

Commit f37910d

Browse files
chore: use config mode for test alias
Co-authored-by: me <me@kentcdodds.com>
1 parent a22426a commit f37910d

1 file changed

Lines changed: 9 additions & 8 deletions

File tree

vite.config.ts

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,12 @@ import { defineConfig } from 'vite'
1010
import { envOnlyMacros } from 'vite-env-only'
1111
import { iconsSpritesheet } from 'vite-plugin-icons-spritesheet'
1212

13-
const MODE = process.env.NODE_ENV
14-
15-
export default defineConfig((config) => ({
13+
export default defineConfig((config) => {
14+
const mode = config.mode ?? process.env.NODE_ENV
15+
return {
1616
build: {
1717
target: 'es2022',
18-
cssMinify: MODE === 'production',
18+
cssMinify: mode === 'production',
1919

2020
rollupOptions: {
2121
input: config.isSsrBuild ? './server/app.ts' : undefined,
@@ -40,7 +40,7 @@ export default defineConfig((config) => ({
4040
},
4141
resolve: {
4242
alias:
43-
MODE === 'test'
43+
mode === 'test'
4444
? {
4545
'#app/utils/cache.server.ts': path.resolve(
4646
'tests/mocks/cache-server.ts',
@@ -63,8 +63,8 @@ export default defineConfig((config) => ({
6363
}),
6464
// it would be really nice to have this enabled in tests, but we'll have to
6565
// wait until https://github.com/remix-run/remix/issues/9871 is fixed
66-
MODE === 'test' ? null : reactRouter(),
67-
MODE === 'production' && process.env.SENTRY_AUTH_TOKEN
66+
mode === 'test' ? null : reactRouter(),
67+
mode === 'production' && process.env.SENTRY_AUTH_TOKEN
6868
? sentryReactRouter(sentryConfig, config)
6969
: null,
7070
],
@@ -78,7 +78,8 @@ export default defineConfig((config) => ({
7878
all: true,
7979
},
8080
},
81-
}))
81+
}
82+
})
8283

8384
const sentryConfig: SentryReactRouterBuildOptions = {
8485
authToken: process.env.SENTRY_AUTH_TOKEN,

0 commit comments

Comments
 (0)