Skip to content

Commit

Permalink
feat: publish every component's css as it's own file as well as the w…
Browse files Browse the repository at this point in the history
…hole bundle
  • Loading branch information
jtiala committed Sep 30, 2023
1 parent adf6be6 commit b002b25
Show file tree
Hide file tree
Showing 7 changed files with 38 additions and 25 deletions.
2 changes: 1 addition & 1 deletion apps/docs/.storybook/preview.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import type { Preview } from "@storybook/react";
import "../node_modules/@themeless-ui/style/dist/style.css";
import "../node_modules/@themeless-ui/style/dist/index.css";

const preview: Preview = {
parameters: {
Expand Down
2 changes: 1 addition & 1 deletion apps/nextjs-example/app/index.css
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
@import "../node_modules/@themeless-ui/style/dist/style.css";
@import "../node_modules/@themeless-ui/style/dist/index.css";

html,
body {
Expand Down
2 changes: 1 addition & 1 deletion apps/react-example/src/index.css
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
@import "../node_modules/@themeless-ui/style/dist/style.css";
@import "../node_modules/@themeless-ui/style/dist/index.css";

/*
Comment below to show only default theme
Expand Down
10 changes: 10 additions & 0 deletions packages/style/src/components.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
@import "./components/anchor.css";
@import "./components/blockquote.css";
@import "./components/button.css";
@import "./components/heading.css";
@import "./components/input.css";
@import "./components/list.css";
@import "./components/paragraph.css";
@import "./components/stack.css";
@import "./components/text.css";
@import "./components/textarea.css";
20 changes: 2 additions & 18 deletions packages/style/src/index.css
Original file line number Diff line number Diff line change
@@ -1,19 +1,3 @@
/* Default theme */
@import "../node_modules/@themeless-ui/theme-default/dist/theme-default.css";

/* Tokens */
@import "./tokens/spacing.css";
@import "./tokens/typography.css";
@import "./tokens/colors.css";

/* Components */
@import "./components/anchor.css";
@import "./components/blockquote.css";
@import "./components/button.css";
@import "./components/heading.css";
@import "./components/input.css";
@import "./components/list.css";
@import "./components/paragraph.css";
@import "./components/stack.css";
@import "./components/text.css";
@import "./components/textarea.css";
@import "./tokens.css";
@import "./components.css";
3 changes: 3 additions & 0 deletions packages/style/src/tokens.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
@import "./tokens/spacing.css";
@import "./tokens/typography.css";
@import "./tokens/colors.css";
24 changes: 20 additions & 4 deletions packages/style/vite.config.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,29 @@
/// <reference types="vite/client" />

import fs from "fs";
import { defineConfig } from "vite";

const componentsDirectory = "./src/components";
const componentInputs = fs
.readdirSync(componentsDirectory)
.map((file) => `${componentsDirectory}/${file}`);

const tokensDirectory = "./src/tokens";
const tokenInputs = fs
.readdirSync(tokensDirectory)
.map((file) => `${tokensDirectory}/${file}`);

const otherInputs = ["src/index.css", "src/tokens.css", "src/components.css"];

export default defineConfig({
build: {
lib: {
entry: "src/index.ts",
name: "style",
fileName: "index",
rollupOptions: {
input: [...componentInputs, ...tokenInputs, ...otherInputs],
output: {
assetFileNames: () => {
return "[name].[ext]";
},
},
},
},
});

0 comments on commit b002b25

Please sign in to comment.