Skip to content

Commit

Permalink
fix: styles monorepo build
Browse files Browse the repository at this point in the history
  • Loading branch information
kirklin committed Jul 3, 2024
1 parent 8a7bd19 commit 5081796
Show file tree
Hide file tree
Showing 8 changed files with 124 additions and 73 deletions.
1 change: 1 addition & 0 deletions apps/admin/src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import { setupRouterGuard } from "~/router/guard";
import App from "~/App.vue";

import "@celeris/styles";
import "uno.css";

const app = createApp(App);

Expand Down
55 changes: 2 additions & 53 deletions packages/shared/vite/src/plugins/unocss.ts
Original file line number Diff line number Diff line change
@@ -1,57 +1,10 @@
import { presetAttributify, presetIcons, presetUno, transformerDirectives, transformerVariantGroup } from "unocss";
import UnoCSS from "unocss/vite";
import presetChinese, { chineseTypography } from "unocss-preset-chinese";
import presetEase from "unocss-preset-ease";
import type { PluginOption } from "vite";
import unoShareConfig from "@celeris/styles/unoconfig";

export function createUnoCSSPluginConfig(): PluginOption {
return UnoCSS({
content: {
pipeline: {
exclude: ["node_modules", ".git", "dist"],
},
},
presets: [
presetUno({ dark: "class" }),
presetAttributify(),
chineseTypography(),
presetChinese({
chineseType: "simplified",
}),
presetEase(),
presetIcons({
scale: 1.2,
warn: true,
}),
],
shortcuts: {
// position
"common-bg": "bg-gray-100 dark:bg-gray-900",
"pr": "relative",
"pa": "absolute",
"pf": "fixed",
"ps": "sticky",

// position layout
"position-x-center": "absolute left-1/2 -translate-x-1/2",
"pxc": "position-x-center",
"position-y-center": "absolute top-1/2 -translate-y-1/2",
"pyc": "position-y-center",
"position-center": "position-x-center position-y-center",
"pc": "position-center",

// size
"size-0": "w-0 h-0",
"size-full": "w-full h-full",
"size-screen": "w-screen h-screen",
"size-1/2": "w-1/2 h-1/2",

// flex layout
"flex-center": "flex justify-center items-center",
"flex-col-center": "flex-center flex-col",
"flex-x-center": "flex justify-center",
"flex-y-center": "flex items-center",
},
...unoShareConfig,
theme: {
colors: {
primary: "var(--primary-color)",
Expand Down Expand Up @@ -87,9 +40,5 @@ export function createUnoCSSPluginConfig(): PluginOption {
error_pressed: "var(--error-color-pressed)",
},
},
transformers: [
transformerDirectives(),
transformerVariantGroup(),
],
});
}
1 change: 0 additions & 1 deletion packages/web/styles/index.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
// reset css
import "@kirklin/reset-css/kirklin.css";
import "./src/index.css";
import "uno.css";
import "animate.css";
25 changes: 18 additions & 7 deletions packages/web/styles/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,28 @@
"author": "Kirk Lin (https://github.com/kirklin)",
"license": "MIT",
"homepage": "https://github.com/kirklin/celeris-web",
"exports": {
".": {
"types": "./dist/index.d.ts",
"import": "./dist/index.js",
"require": "./dist/index.cjs"
},
"./unoconfig": "./uno.config.ts"
},
"files": [
"src",
"uno.config.ts"
],
"main": "./index.ts",

Check failure on line 21 in packages/web/styles/package.json

View workflow job for this annotation

GitHub Actions / LINT

Expected object keys to be in specified order. 'main' should be before 'files'
"module": "./index.ts",
"scripts": {
"clean": "pnpm rimraf node_modules && pnpm rimraf dist"
"build": "tsup",
"dev": "tsup --stub",
"clean": "pnpm rimraf node_modules && pnpm rimraf dist",
"prepublishOnly": "nr build"
},
"peerDependencies": {
"unocss": "^0.51.13"
"unocss": "^0.61.0"
},
"dependencies": {
"@kirklin/reset-css": "^0.0.6",
Expand All @@ -21,12 +36,8 @@
"unocss-preset-ease": "^0.0.3"
},
"devDependencies": {
"@css-render/plugin-bem": "^0.15.14",
"@css-render/vue3-ssr": "^0.15.14",
"@iconify/json": "^2.2.222",
"@iconify/vue": "4.1.2",
"css-render": "^0.15.14",
"unocss": "^0.61.0",
"vite": "^5.3.1"
"unocss": "^0.61.0"
}
}
23 changes: 23 additions & 0 deletions packages/web/styles/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
{
"extends": "@celeris/tsconfig/tsconfig.base.json",
"compilerOptions": {
"target": "esnext",
"baseUrl": ".",
"module": "esnext",
"moduleResolution": "Bundler",
"strict": true,
"skipLibCheck": true,
"allowSyntheticDefaultImports": true,

Check failure on line 10 in packages/web/styles/tsconfig.json

View workflow job for this annotation

GitHub Actions / LINT

Expected object keys to be in specified order. 'allowSyntheticDefaultImports' should be before 'skipLibCheck'
"sourceMap": false,

Check failure on line 11 in packages/web/styles/tsconfig.json

View workflow job for this annotation

GitHub Actions / LINT

Expected object keys to be in specified order. 'sourceMap' should be before 'allowSyntheticDefaultImports'
"lib": [

Check failure on line 12 in packages/web/styles/tsconfig.json

View workflow job for this annotation

GitHub Actions / LINT

Expected object keys to be in specified order. 'lib' should be before 'sourceMap'
"esnext",
"dom"
]
},
"include": [
"src/**/*.ts"
],
"exclude": [
"node_modules"
]
}
10 changes: 10 additions & 0 deletions packages/web/styles/tsup.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import { defineConfig } from "tsup";

export default defineConfig({
entry: ["./index.ts"],
clean: true,
format: ["esm", "cjs", "iife"],
external: ["vite"],
dts: true,
minify: true,
});
70 changes: 70 additions & 0 deletions packages/web/styles/uno.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
// uno.config.ts
import type {
UserConfig,
} from "unocss";
import {
presetAttributify,
presetIcons,
presetUno,
transformerDirectives,
transformerVariantGroup,
} from "unocss";
import presetChinese, { chineseTypography } from "unocss-preset-chinese";
import presetEase from "unocss-preset-ease";

const shareConfig: UserConfig = {
content: {
pipeline: {
exclude: ["node_modules", ".git", "dist"],
},
},
presets: [
presetUno({ dark: "class" }),
presetAttributify(),
chineseTypography(),
presetChinese({
chineseType: "simplified",
}),
presetEase(),
presetIcons({
scale: 1.2,
warn: true,
}),
],
shortcuts: {
// position
"common-bg": "bg-gray-100 dark:bg-gray-900",
"pr": "relative",
"pa": "absolute",
"pf": "fixed",
"ps": "sticky",

// position layout
"position-x-center": "absolute left-1/2 -translate-x-1/2",
"pxc": "position-x-center",
"position-y-center": "absolute top-1/2 -translate-y-1/2",
"pyc": "position-y-center",
"position-center": "position-x-center position-y-center",
"pc": "position-center",

// size
"size-0": "w-0 h-0",
"size-full": "w-full h-full",
"size-screen": "w-screen h-screen",
"size-1/2": "w-1/2 h-1/2",

// flex layout
"flex-center": "flex justify-center items-center",
"flex-col-center": "flex-center flex-col",
"flex-x-center": "flex justify-center",
"flex-y-center": "flex items-center",
},
theme: {
},
transformers: [
transformerDirectives(),
transformerVariantGroup(),
],
};

export default shareConfig;
12 changes: 0 additions & 12 deletions pnpm-lock.yaml

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

0 comments on commit 5081796

Please sign in to comment.