Skip to content

Commit

Permalink
Refactor packaging, compile tsc & tailwind
Browse files Browse the repository at this point in the history
  • Loading branch information
tdraier committed Aug 11, 2024
1 parent 2b495e8 commit a1d171a
Show file tree
Hide file tree
Showing 35 changed files with 586 additions and 1,070 deletions.
1 change: 1 addition & 0 deletions sparkle/.eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ module.exports = {
ignorePatterns: [
"rollup.config.js",
"eslint.js",
".eslintrc.js",
"dist/",
"node_modules/",
"svgr.config.js",
Expand Down
152 changes: 152 additions & 0 deletions sparkle/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 9 additions & 3 deletions sparkle/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,19 @@
"name": "@dust-tt/sparkle",
"version": "0.2.203",
"scripts": {
"build": "rm -rf dist && rollup -c",
"build:with-tw-base": "rollup -c --environment INCLUDE_TW_BASE:true",
"build": "rm -rf dist && npm run tailwind && npm run build:esm && npm run build:cjs",
"tailwind": "tailwindcss -i ./src/styles/tailwind.css -o dist/sparkle.css",
"build:esm": "npm run copy:esm && tsc && tsc-alias",
"copy:esm": "copyfiles -u 1 src/**/*.css src/**/*.svg src/**/*.png src/**/*.json dist/esm",
"build:cjs": "rollup -c",
"storybook": "storybook dev -p 6006 --debug-webpack",
"build-storybook": "storybook build",
"format:check": "prettier --check .",
"format": "prettier --write .",
"lint": "eslint ."
},
"main": "dist/cjs/index.js",
"types": "dist/cjs/index.d.ts",
"types": "dist/esm/index.d.ts",
"module": "dist/esm/index.js",
"files": [
"dist/",
Expand Down Expand Up @@ -45,6 +48,7 @@
"autoprefixer": "^10.4.14",
"babel-loader": "^9.1.3",
"babel-preset-react-app": "^10.0.1",
"copyfiles": "^2.4.1",
"eslint": "^8.56.0",
"eslint-config-prettier": "^9.1.0",
"eslint-plugin-simple-import-sort": "^12.1.0",
Expand All @@ -60,7 +64,9 @@
"sass-loader": "^13.3.2",
"storybook": "^7.4.6",
"tailwindcss": "^3.2.4",
"tsc-alias": "^1.8.10",
"typescript": "^5.4.5",
"typescript-transform-paths": "^3.4.7",
"uuid": "^9.0.1"
},
"peerDependencies": {
Expand Down
19 changes: 1 addition & 18 deletions sparkle/rollup.config.mjs
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import commonjs from "@rollup/plugin-commonjs";
import json from "@rollup/plugin-json";
import resolve from "@rollup/plugin-node-resolve";
import typescript from "@rollup/plugin-typescript";
import autoprefixer from "autoprefixer";
import fs from "fs";
import path from "path";
Expand All @@ -10,23 +9,13 @@ import postcss from "rollup-plugin-postcss";
import tailwindcss from "tailwindcss";
import { fileURLToPath } from "url";

let tsPluginOptions = {
tsconfig: "./tsconfig.json",
outputToFilesystem: true,
};

const __dirname = path.dirname(fileURLToPath(import.meta.url));

const pkg = JSON.parse(
fs.readFileSync(path.resolve(__dirname, "package.json"), "utf-8")
);

let entryFile = "src/index.ts";
tsPluginOptions.exclude = "src/index_with_tw_base.ts";
if (process.env.INCLUDE_TW_BASE) {
entryFile = "src/index_with_tw_base.ts";
tsPluginOptions.exclude = "src/index.ts";
}
let entryFile = "dist/esm/index.js";

const config = {
input: entryFile,
Expand All @@ -37,17 +26,11 @@ const config = {
sourcemap: true,
name: "react-lib",
},
{
file: pkg.module,
format: "esm",
sourcemap: true,
},
],
plugins: [
external(),
resolve(),
commonjs(),
typescript(tsPluginOptions),
postcss({
plugins: [
tailwindcss({
Expand Down
Loading

0 comments on commit a1d171a

Please sign in to comment.