Skip to content

Commit

Permalink
fix(ui-styles): missing CSS in all new independent packages in prod (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
aversini authored Sep 18, 2024
1 parent 8ccdf4a commit cc0d971
Show file tree
Hide file tree
Showing 2 changed files with 67 additions and 12 deletions.
56 changes: 46 additions & 10 deletions packages/ui-styles/src/plugins/__tests__/tailwindPlugin.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,12 @@ import { customContentPath } from "../tailwindcss/tailwindPlugin";

describe("Non-DOM tests", () => {
it("should return an array with ui-system and ui-components", () => {
expect(customContentPath[0]).toContain(
"node_modules/@versini/ui-components",
);
expect(customContentPath[1]).toContain("node_modules/@versini/ui-form");
expect(customContentPath[2]).toContain("node_modules/@versini/ui-icons");
expect(customContentPath[3]).toContain("node_modules/@versini/ui-system");
expect(
customContentPath.some((path) => path.includes("ui-system")),
).toBeTruthy();
expect(
customContentPath.some((path) => path.includes("ui-components")),
).toBeTruthy();
});

it("should return a default configuration", () => {
Expand All @@ -20,10 +20,28 @@ describe("Non-DOM tests", () => {
const content = (mergedConfig.content as string[]).join(" ");

expect(content).not.toContain("./src/*.{js,ts,jsx,tsx}");
expect(content).toContain("node_modules/@versini/ui-components");
expect(content).toContain("node_modules/@versini/ui-form");

expect(content).toContain("node_modules/@versini/ui-anchor");
expect(content).toContain("node_modules/@versini/ui-bubble");
expect(content).toContain("node_modules/@versini/ui-button");
expect(content).toContain("node_modules/@versini/ui-card");
expect(content).toContain("node_modules/@versini/ui-footer");
expect(content).toContain("node_modules/@versini/ui-header");
expect(content).toContain("node_modules/@versini/ui-hooks");
expect(content).toContain("node_modules/@versini/ui-icons");
expect(content).toContain("node_modules/@versini/ui-main");
expect(content).toContain("node_modules/@versini/ui-menu");
expect(content).toContain("node_modules/@versini/ui-panel");
expect(content).toContain("node_modules/@versini/ui-pill");
expect(content).toContain("node_modules/@versini/ui-private");
expect(content).toContain("node_modules/@versini/ui-spinner");
expect(content).toContain("node_modules/@versini/ui-system");
expect(content).toContain("node_modules/@versini/ui-table");
expect(content).toContain("node_modules/@versini/ui-textarea");
expect(content).toContain("node_modules/@versini/ui-textinput");
expect(content).toContain("node_modules/@versini/ui-toggle");
expect(content).toContain("node_modules/@versini/ui-components");
expect(content).toContain("node_modules/@versini/ui-form");

expect(mergedConfig.safelist).toContain("mt-0");
expect(mergedConfig.safelist).toContain("mt-52");
Expand All @@ -45,10 +63,28 @@ describe("Non-DOM tests", () => {
const content = (mergedConfig.content as string[]).join(" ");

expect(content).toContain("./src/*.{js,ts,jsx,tsx}");
expect(content).toContain("node_modules/@versini/ui-components");
expect(content).toContain("node_modules/@versini/ui-form");

expect(content).toContain("node_modules/@versini/ui-anchor");
expect(content).toContain("node_modules/@versini/ui-bubble");
expect(content).toContain("node_modules/@versini/ui-button");
expect(content).toContain("node_modules/@versini/ui-card");
expect(content).toContain("node_modules/@versini/ui-footer");
expect(content).toContain("node_modules/@versini/ui-header");
expect(content).toContain("node_modules/@versini/ui-hooks");
expect(content).toContain("node_modules/@versini/ui-icons");
expect(content).toContain("node_modules/@versini/ui-main");
expect(content).toContain("node_modules/@versini/ui-menu");
expect(content).toContain("node_modules/@versini/ui-panel");
expect(content).toContain("node_modules/@versini/ui-pill");
expect(content).toContain("node_modules/@versini/ui-private");
expect(content).toContain("node_modules/@versini/ui-spinner");
expect(content).toContain("node_modules/@versini/ui-system");
expect(content).toContain("node_modules/@versini/ui-table");
expect(content).toContain("node_modules/@versini/ui-textarea");
expect(content).toContain("node_modules/@versini/ui-textinput");
expect(content).toContain("node_modules/@versini/ui-toggle");
expect(content).toContain("node_modules/@versini/ui-components");
expect(content).toContain("node_modules/@versini/ui-form");

expect(mergedConfig.safelist).toContain("mt-0");
expect(mergedConfig.safelist).toContain("mt-52");
Expand Down
23 changes: 21 additions & 2 deletions packages/ui-styles/src/plugins/tailwindcss/tailwindPlugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,29 @@ export type TailwindConfig = {
* added here.
*/
export const customContentPath = [
"@versini/ui-components",
"@versini/ui-form",
"@versini/ui-anchor",
"@versini/ui-bubble",
"@versini/ui-button",
"@versini/ui-card",
"@versini/ui-footer",
"@versini/ui-header",
"@versini/ui-hooks",
"@versini/ui-icons",
"@versini/ui-main",
"@versini/ui-menu",
"@versini/ui-panel",
"@versini/ui-pill",
"@versini/ui-private",
"@versini/ui-spinner",
"@versini/ui-system",
"@versini/ui-table",
"@versini/ui-textarea",
"@versini/ui-textinput",
"@versini/ui-toggle",

// the following are legacy packages and should eventually be removed
"@versini/ui-components",
"@versini/ui-form",
].map(
(pkg) => `${process.cwd()}/node_modules/${pkg}/dist/**/*.{js,ts,jsx,tsx}`,
);
Expand Down

0 comments on commit cc0d971

Please sign in to comment.