Skip to content

Commit

Permalink
fix ci/cd
Browse files Browse the repository at this point in the history
  • Loading branch information
vorant94 committed Dec 15, 2024
1 parent df804c4 commit e58e3c9
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 23 deletions.
16 changes: 16 additions & 0 deletions dotenv.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import process from "node:process";
import dotenv from "dotenv";
import { z } from "zod";

const { error, parsed } = dotenv.config();

export default z
.object({
// biome-ignore lint/style/useNamingConvention: env variables have different convention
NODE_ENV: z
.enum(["development", "production", "test"])
.default("development"),
// biome-ignore lint/style/useNamingConvention: env variables have different convention
CI: z.coerce.boolean().default(false),
})
.parse(error ? process.env : parsed);
14 changes: 7 additions & 7 deletions playwright.config.ts
Original file line number Diff line number Diff line change
@@ -1,28 +1,28 @@
import { defineConfig, devices } from "@playwright/test";
import { config } from "./vite.config.ts";
import dotenvConfig from "./dotenv.config";

export default defineConfig({
testDir: "./e2e",
fullyParallel: true,
forbidOnly: config.CI,
retries: config.CI ? 2 : 0,
workers: config.CI ? 1 : undefined,
forbidOnly: dotenvConfig.CI,
retries: dotenvConfig.CI ? 2 : 0,
workers: dotenvConfig.CI ? 1 : undefined,
reporter: "html",
use: {
// biome-ignore lint/style/useNamingConvention: 3-rd party type
baseURL:
config.NODE_ENV === "production"
dotenvConfig.NODE_ENV === "production"
? "https://subs-savvy.pages.dev"
: "http://localhost:5173",
trace: "retain-on-failure",
...devices["Desktop Chrome"],
},
webServer:
config.NODE_ENV === "production"
dotenvConfig.NODE_ENV === "production"
? undefined
: {
command: "npm run start:dev",
url: "http://localhost:5173",
reuseExistingServer: !config.CI,
reuseExistingServer: !dotenvConfig.CI,
},
});
18 changes: 2 additions & 16 deletions vite.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ import process from "node:process";
import { reactRouter } from "@react-router/dev/vite";
import autoprefixer from "autoprefixer";
import cssnano from "cssnano";
import dotenv from "dotenv";
import { i18nextHMRPlugin } from "i18next-hmr/vite";
import postcssNested from "postcss-nested";
import postcssPresetMantine from "postcss-preset-mantine";
Expand All @@ -13,20 +12,7 @@ import tailwindcssNesting from "tailwindcss/nesting";
import { defineConfig } from "vite";
import { VitePWA } from "vite-plugin-pwa";
import svgr from "vite-plugin-svgr";
import { z } from "zod";

const { error, parsed } = dotenv.config();

export const config = z
.object({
// biome-ignore lint/style/useNamingConvention: env variables have different convention
NODE_ENV: z
.enum(["development", "production", "test"])
.default("development"),
// biome-ignore lint/style/useNamingConvention: env variables have different convention
CI: z.coerce.boolean().default(false),
})
.parse(error ? process.env : parsed);
import dotenvConfig from "./dotenv.config.ts";

export default defineConfig({
// inlining PostCSS config instead of separate file, because of this
Expand All @@ -53,7 +39,7 @@ export default defineConfig({
},
},
plugins: [
config.NODE_ENV !== "test" && reactRouter(),
dotenvConfig.NODE_ENV !== "test" && reactRouter(),
svgr(),
i18nextHMRPlugin({
localesDir: path.resolve(process.cwd(), "public/locales"),
Expand Down

0 comments on commit e58e3c9

Please sign in to comment.