From 33f6a7e0c2cf92f33ad9947c7d15582d3318d5ca Mon Sep 17 00:00:00 2001 From: Jay Date: Fri, 1 Aug 2025 23:50:24 -0400 Subject: [PATCH] Make alias imports work in cypress. --- cypress.config.ts | 15 ++++++++++----- package.json | 2 ++ tsconfig.node.json | 2 +- vite.config.ts | 2 +- 4 files changed, 14 insertions(+), 7 deletions(-) diff --git a/cypress.config.ts b/cypress.config.ts index f1bc680..b002550 100644 --- a/cypress.config.ts +++ b/cypress.config.ts @@ -1,9 +1,12 @@ import { defineConfig } from "cypress"; import vitePreprocessor from "cypress-vite"; +import { mergeConfig } from "vite"; + +import viteConfig from "./vite.config"; export default defineConfig({ e2e: { - setupNodeEvents(on, config) { + setupNodeEvents(on, _) { on("file:preprocessor", vitePreprocessor()); }, baseUrl: "http://localhost:5173", @@ -13,10 +16,12 @@ export default defineConfig({ devServer: { framework: "react", bundler: "vite", - viteConfig: { - server: { - port: 5174, - }, + viteConfig: () => { + return mergeConfig(viteConfig, { + server: { + port: 5174, + }, + }); }, }, }, diff --git a/package.json b/package.json index 7f90ce3..8d57afe 100644 --- a/package.json +++ b/package.json @@ -7,6 +7,8 @@ "build:wasm": "wasm-pack build colorlib -t bundler -d pkg --release", "clean": "rm -rf dist colorlib/pkg*", "cypress:open": "1>/dev/null 2>/dev/null cypress open -d &", + "cypress:component": "cypress run --component", + "cypress:e2e": "cypress run --e2e", "dev": "vite", "lint": "eslint .", "preview": "vite preview", diff --git a/tsconfig.node.json b/tsconfig.node.json index d9aa8a8..ee3a473 100644 --- a/tsconfig.node.json +++ b/tsconfig.node.json @@ -20,5 +20,5 @@ "noFallthroughCasesInSwitch": true, "noUncheckedSideEffectImports": true }, - "include": ["vite.config.ts"] + "include": ["vite.config.ts", "cypress.config.ts"] } diff --git a/vite.config.ts b/vite.config.ts index 66f23a9..a749574 100644 --- a/vite.config.ts +++ b/vite.config.ts @@ -1,6 +1,6 @@ import react from "@vitejs/plugin-react"; -import path from "path"; +import * as path from "path"; import { defineConfig } from "vite"; import topLevelAwait from "vite-plugin-top-level-await"; import wasm from "vite-plugin-wasm";