Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Fix]: theme, ui 패키지의 vanilla-extract 빌드 설정 수정 #45

Merged
merged 13 commits into from
Jan 4, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 0 additions & 13 deletions apps/web/next.config.js

This file was deleted.

File renamed without changes.
1 change: 0 additions & 1 deletion apps/web/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@
"@types/react": "18.3.0",
"@types/react-dom": "18.3.1",
"@vanilla-extract/next-plugin": "^2.4.8",
"eslint": "^8",
"eslint-config-next": "14.2.21",
"typescript": "5.5.4"
}
Expand Down
2 changes: 2 additions & 0 deletions apps/web/src/app/layout.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import type { Metadata } from 'next';
import localFont from 'next/font/local';
import './globals.css';
//import '@repo/ui/styles';
import '@repo/theme/styles';

const geistSans = localFont({
src: './fonts/GeistVF.woff',
Expand Down
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
"node": ">=18"
},
"dependencies": {
"@vanilla-extract/css": "^1.17.0"
"@vanilla-extract/css": "^1.17.0",
"@vanilla-extract/recipes": "^0.5.5"
}
}
2 changes: 0 additions & 2 deletions packages/eslint-config/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,6 @@
"@eslint/js": "^9.17.0",
"@next/eslint-plugin-next": "^15.1.0",
"@typescript-eslint/eslint-plugin": "^8.15.0",
"@typescript-eslint/parser": "^8.15.0",
"eslint": "^9.15.0",
"eslint-config-prettier": "^9.1.0",
"eslint-plugin-only-warn": "^1.1.0",
"eslint-plugin-react": "^7.37.2",
Expand Down
15 changes: 0 additions & 15 deletions packages/theme/esbuild.config.js

This file was deleted.

24 changes: 24 additions & 0 deletions packages/theme/esbuild.config.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
import { vanillaExtractPlugin } from '@vanilla-extract/esbuild-plugin';
import esbuild from 'esbuild';
import { preserveDirectivesPlugin } from 'esbuild-plugin-preserve-directives';
import path from 'path';

const outdir = path.join(process.cwd(), 'dist');
esbuild
.build({
entryPoints: ['./src/index.ts'],
bundle: true,
plugins: [
vanillaExtractPlugin(),
preserveDirectivesPlugin({
directives: ['use client', 'use strict'],
include: /\.(js|ts|jsx|tsx)$/,
exclude: /node_modules/,
}),
],
format: 'esm',
loader: { '.css': 'file' },
outdir,
external: ['react', 'react-dom'],
})
.catch(() => process.exit(1));
13 changes: 9 additions & 4 deletions packages/theme/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,15 @@
"name": "@repo/theme",
"version": "0.0.0",
"private": true,
"main": "./dist/index.js",
"module": "./dist/index.mjs",
"types": "./dist/index.d.ts",
"exports": {
".": {
"import": "./dist/index.js"
},
"./styles": "./dist/index.css"
},
"scripts": {
"build": "tsc --emitDeclarationOnly && esbuild src/index.ts --bundle --platform=node --format=esm --outfile=dist/index.mjs && esbuild src/index.ts --bundle --platform=node --format=cjs --outfile=dist/index.js",
"build": "tsc && node esbuild.config.mjs",
"dev": "esbuild src/index.ts --bundle --platform=node --format=esm --outfile=dist/index.mjs --watch",
"lint": "eslint . --max-warnings 0"
},
Expand All @@ -18,6 +22,7 @@
},
"devDependencies": {
"@vanilla-extract/esbuild-plugin": "^2.3.5",
"esbuild": "^0.24.0"
"esbuild": "^0.21.0",
"esbuild-plugin-preserve-directives": "^0.0.11"
}
}
2 changes: 1 addition & 1 deletion packages/theme/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
export * from './tokens';
export * from './themes';
export * from './sprinkles.css';
export * from './sprinkles';
1 change: 1 addition & 0 deletions packages/theme/src/sprinkles/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export { sprinkles } from './sprinkles.css';
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { defineProperties, createSprinkles } from '@vanilla-extract/sprinkles';
import { vars } from './themes';
import { vars } from '../themes';

const colorProperties = defineProperties({
properties: {
Expand Down
12 changes: 3 additions & 9 deletions packages/theme/src/themes/index.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,5 @@
import { createTheme } from '@vanilla-extract/css';
import { lightTheme } from './light';
import { darkTheme } from './dark';
import type { ThemeContract } from './contract';
import { vars } from './themes.css';

const [lightThemeClass, vars] = createTheme<ThemeContract>(lightTheme);
const darkThemeClass = createTheme(vars, darkTheme);

export { lightThemeClass, darkThemeClass, vars };
export type { ThemeContract };
export * from './themes.css';
export type { ThemeContract } from './contract';
export type Vars = typeof vars;
7 changes: 7 additions & 0 deletions packages/theme/src/themes/themes.css.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import { createTheme } from '@vanilla-extract/css';
import { lightTheme } from './light';
import { darkTheme } from './dark';
import type { ThemeContract } from './contract';

export const [lightThemeClass, vars] = createTheme<ThemeContract>(lightTheme);
export const darkThemeClass = createTheme(vars, darkTheme);
15 changes: 0 additions & 15 deletions packages/ui/esbuild.config.js

This file was deleted.

24 changes: 24 additions & 0 deletions packages/ui/esbuild.config.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
import { vanillaExtractPlugin } from '@vanilla-extract/esbuild-plugin';
import esbuild from 'esbuild';
import { preserveDirectivesPlugin } from 'esbuild-plugin-preserve-directives';
import path from 'path';

const outdir = path.join(process.cwd(), 'dist');
esbuild
.build({
entryPoints: ['./src/index.ts'],
bundle: true,
plugins: [
vanillaExtractPlugin(),
preserveDirectivesPlugin({
directives: ['use client', 'use strict'],
include: /\.(js|ts|jsx|tsx)$/,
exclude: /node_modules/,
}),
],
format: 'esm',
loader: { '.css': 'file' },
outdir,
external: ['react', 'react-dom'],
})
.catch(() => process.exit(1));
13 changes: 9 additions & 4 deletions packages/ui/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,15 @@
"name": "@repo/ui",
"version": "0.0.0",
"private": true,
"main": "./dist/index.js",
"module": "./dist/index.mjs",
"types": "./dist/index.d.ts",
"exports": {
".": {
"import": "./dist/index.js"
},
"./styles": "./dist/index.css"
},
"scripts": {
"build": "tsc --emitDeclarationOnly && esbuild src/index.ts --bundle --platform=node --format=esm --outfile=dist/index.mjs && esbuild src/index.ts --bundle --platform=node --format=cjs --outfile=dist/index.js",
"build": "tsc && node esbuild.config.mjs",
"dev": "esbuild src/index.ts --bundle --platform=node --format=esm --outfile=dist/index.mjs --watch",
"lint": "eslint . --max-warnings 0"
},
Expand All @@ -19,7 +23,8 @@
"devDependencies": {
"@types/react": "^18.2.0",
"@vanilla-extract/esbuild-plugin": "^2.3.5",
"esbuild": "^0.24.0"
"esbuild": "^0.21.0",
"esbuild-plugin-preserve-directives": "^0.0.11"
},
"peerDependencies": {
"react": "^18.2.0"
Expand Down
Loading
Loading