diff --git a/packages/ui-plugins/package.json b/packages/ui-plugins/package.json index 3d5edcae..12158d5a 100644 --- a/packages/ui-plugins/package.json +++ b/packages/ui-plugins/package.json @@ -28,6 +28,12 @@ "dev": "npm-run-all clean --parallel dev:js dev:types", "lint": "eslint src --ext ts,tsx --report-unused-disable-directives --max-warnings 0 --fix --color", "test:coverage": "echo \"WARNING: no test specified\" && exit 0", - "test": "echo \"WARNING: no test specified\" && exit 0" + "test:watch": "vitest", + "test": "cross-env-shell NODE_ENV=test vitest run" + }, + "dependencies": { + "@tailwindcss/typography": "0.5.10", + "culori": "4.0.1", + "tailwindcss": "3.4.1" } } diff --git a/packages/ui-plugins/src/plugins/__tests__/tailwindPlugin.test.ts b/packages/ui-plugins/src/plugins/__tests__/tailwindPlugin.test.ts new file mode 100644 index 00000000..6383c4fb --- /dev/null +++ b/packages/ui-plugins/src/plugins/__tests__/tailwindPlugin.test.ts @@ -0,0 +1,10 @@ +import { describe, expect, it } from "vitest"; + +import { tailwindContentPath } from "../tailwindPlugin"; + +describe("Non-DOM tests", () => { + it("should return an array with ui-system and ui-components", () => { + expect(tailwindContentPath[0]).toContain("ui-system"); + expect(tailwindContentPath[1]).toContain("ui-components"); + }); +}); diff --git a/packages/ui-plugins/src/plugins/tailwindPlugin.ts b/packages/ui-plugins/src/plugins/tailwindPlugin.ts index 02daa09f..dc132a36 100644 --- a/packages/ui-plugins/src/plugins/tailwindPlugin.ts +++ b/packages/ui-plugins/src/plugins/tailwindPlugin.ts @@ -10,6 +10,18 @@ type TailwindConfig = { content: string[]; } & OptionalConfig; +export const isTest = process.env.NODE_ENV === "test"; + +const packagesList = ["ui-system", "ui-components"]; +const distLocation = isTest ? "src" : "dist"; + +export const tailwindContentPath = packagesList.map((pkg) => + `${__dirname}/**/*.{js,ts,jsx,tsx}`.replace( + `ui-plugins/${distLocation}`, + `${pkg}/${distLocation}`, + ), +); + const parse = converter("rgb"); const dynamicColors = () => { @@ -148,17 +160,6 @@ const myComponentLibraryConfig = { }, }; -const tailwindContentPath = [ - (__dirname + "/**/*.{js,ts,jsx,tsx}").replace( - "ui-plugins/dist", - "ui-system/dist", - ), - (__dirname + "/**/*.{js,ts,jsx,tsx}").replace( - "ui-plugins/dist", - "ui-components/dist", - ), -]; - const tailwindPlugins = [ typography, plugin(function ({ addUtilities }) { diff --git a/packages/ui-plugins/vitest.config.ts b/packages/ui-plugins/vitest.config.ts index 10f38968..ab07d97a 100644 --- a/packages/ui-plugins/vitest.config.ts +++ b/packages/ui-plugins/vitest.config.ts @@ -4,9 +4,9 @@ import { defineConfig, mergeConfig } from "vitest/config"; import viteConfig from "./vite.config"; -export default defineConfig((configEnv) => +export default defineConfig(() => mergeConfig( - viteConfig(configEnv), + viteConfig, defineConfig({ test: { globals: true, diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 3ca97b51..b0caa549 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -163,7 +163,17 @@ importers: specifier: workspace:../ui-plugins version: link:../ui-plugins - packages/ui-plugins: {} + packages/ui-plugins: + dependencies: + '@tailwindcss/typography': + specifier: 0.5.10 + version: 0.5.10(tailwindcss@3.4.1) + culori: + specifier: 4.0.1 + version: 4.0.1 + tailwindcss: + specifier: 3.4.1 + version: 3.4.1 packages/ui-private: dependencies: @@ -4005,7 +4015,6 @@ packages: /culori@4.0.1: resolution: {integrity: sha512-LSnjA6HuIUOlkfKVbzi2OlToZE8OjFi667JWN9qNymXVXzGDmvuP60SSgC+e92sd7B7158f7Fy3Mb6rXS5EDPw==} engines: {node: ^12.20.0 || ^14.13.1 || >=16.0.0} - dev: true /dargs@7.0.0: resolution: {integrity: sha512-2iy1EkLdlBzQGvbweYRFxmFath8+K7+AKB0TlhHWkNuH+TmovaMH/Wp7V7R4u7f4SnX3OgLsU9t1NI9ioDnUpg==}