Skip to content

Commit

Permalink
Split parts into subpackages
Browse files Browse the repository at this point in the history
  • Loading branch information
pervoj committed Apr 1, 2024
1 parent 1ed9049 commit 60ce602
Show file tree
Hide file tree
Showing 6 changed files with 23 additions and 13 deletions.
11 changes: 7 additions & 4 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,16 @@ jobs:
- name: Build the package
run: |
npm install
npm run build
LIB_ENTRY=components npm run build
LIB_ENTRY=utils npm run build
LIB_ENTRY=theme npm run build
cp src/index.d.ts dist/
- name: Prepare files for archiving
env:
FILES: package.json package-lock.json dist
FILES: package.json package-lock.json
run: |
mkdir luminar
cp -r $FILES luminar
cp -r $FILES dist
mv dist luminar
- name: Archive the built package
uses: TheDoctor0/[email protected]
with:
Expand Down
3 changes: 1 addition & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,7 @@
"private": true,
"version": "0.0.3",
"type": "module",
"main": "dist/index.js",
"types": "dist/index.d.ts",
"types": "index.d.ts",
"scripts": {
"lint": "eslint . --ext ts,tsx --report-unused-disable-directives --max-warnings 0",
"build": "tsc && vite build",
Expand Down
2 changes: 2 additions & 0 deletions src/components/index.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import "../globals.css";

export * from "./Card";
export * from "./FixedBanner";
export * from "./FormButton";
Expand Down
3 changes: 3 additions & 0 deletions src/index.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
export * as components from "./components";
export * as theme from "./theme";
export * as utils from "./utils";
5 changes: 0 additions & 5 deletions src/index.ts

This file was deleted.

12 changes: 10 additions & 2 deletions vite.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,21 @@ import { defineConfig } from "vite";
import dts from "vite-plugin-dts";
import { libInjectCss } from "vite-plugin-lib-inject-css";

const entries = ["components", "utils", "theme"];
const entry = process.env.LIB_ENTRY || entries[0];

if (!entries.includes(entry)) {
throw new Error(`'${entry}' is not a valid entry`);
}

// https://vitejs.dev/config/
export default defineConfig({
plugins: [react(), libInjectCss(), dts()],
plugins: [react(), libInjectCss(), dts({ entryRoot: `src/${entry}` })],
build: {
copyPublicDir: false,
outDir: `dist/${entry}`,
lib: {
entry: resolve(__dirname, "src/index.ts"),
entry: resolve(__dirname, `src/${entry}/index.ts`),
fileName: "index",
formats: ["es"],
},
Expand Down

0 comments on commit 60ce602

Please sign in to comment.