@inkdropapp/theme-dev-helpers 0.3.1 → 0.3.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -36,3 +36,12 @@ If your theme package name doesn't include 'dark' but it is a dark mode:
36
36
  ```sh
37
37
  generate-palette -a dark
38
38
  ```
39
+
40
+ ## Run dev server
41
+
42
+ It provides a simple UI to preview your theme with hot-reloading.
43
+
44
+ ```sh
45
+ dev-server
46
+ ```
47
+
package/bin/dev-server ADDED
@@ -0,0 +1,6 @@
1
+ #!/usr/bin/env bash
2
+
3
+ SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
4
+ echo $SCRIPT_DIR
5
+
6
+ bunx --bun vite "$SCRIPT_DIR/.."
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@inkdropapp/theme-dev-helpers",
3
- "version": "0.3.1",
3
+ "version": "0.3.3",
4
4
  "type": "module",
5
5
  "description": "A helper module for creating themes for Inkdrop",
6
6
  "keywords": [
@@ -8,7 +8,6 @@
8
8
  "markdown"
9
9
  ],
10
10
  "scripts": {
11
- "dev-server": "bunx --bun vite",
12
11
  "test": "echo \"Error: no test specified\" && exit 1"
13
12
  },
14
13
  "repository": {
@@ -18,7 +17,8 @@
18
17
  "author": "Takuya Matsuyama<t@inkdrop.app>",
19
18
  "license": "MIT",
20
19
  "bin": {
21
- "generate-palette": "./bin/generate-palette"
20
+ "generate-palette": "./bin/generate-palette",
21
+ "dev-server": "./bin/dev-server"
22
22
  },
23
23
  "dependencies": {
24
24
  "@inkdropapp/base-ui-theme": "^0.3.1",
@@ -6,21 +6,18 @@ import "./dev-server.css";
6
6
  import "@inkdropapp/css/reset.css";
7
7
  import "@inkdropapp/css/tokens.css";
8
8
  import "@inkdropapp/base-ui-theme/styles/theme.css";
9
- import "@/styles/tokens.css";
10
- import "@/styles/theme.css";
11
9
 
12
10
  import { ColorTokensPage } from "./dev-server/color-tokens";
13
11
  import { VariablesPage } from "./dev-server/variables";
14
12
  import { ComponentsPage } from "./dev-server/components";
13
+ const baseProjectPath = import.meta.env.BASE_PROJECT_PATH || ''
14
+ const styleSheets: string[] = import.meta.env.STYLE_SHEETS || []
15
15
 
16
- // const cssFiles = [
17
- // "@/styles/tokens.css",
18
- // "@/styles/theme.css",
19
- // ];
20
- //
21
- // cssFiles.forEach((file) => {
22
- // import(/* @vite-ignore */ file);
23
- // });
16
+ const cssFiles = styleSheets.map(ss => `${baseProjectPath}/styles/${ss}`)
17
+
18
+ cssFiles.forEach((file) => {
19
+ import(file);
20
+ });
24
21
 
25
22
  const router = createBrowserRouter([
26
23
  {
@@ -0,0 +1,10 @@
1
+ /// <reference types="vite/client" />
2
+
3
+ interface ImportMetaEnv {
4
+ readonly BASE_PROJECT_PATH: string
5
+ readonly STYLE_SHEETS: string[]
6
+ }
7
+
8
+ interface ImportMeta {
9
+ readonly env: ImportMetaEnv
10
+ }
package/vite.config.ts CHANGED
@@ -1,9 +1,14 @@
1
- import { fileURLToPath, URL } from 'url'
2
1
  import { defineConfig } from 'vite'
3
2
  import react from '@vitejs/plugin-react'
4
3
 
5
- const baseProjectPath = process.env.BASE_PROJECT_PATH || fileURLToPath(new URL('../../..', import.meta.url))
4
+ const baseProjectPath = process.env.BASE_PROJECT_PATH || process.cwd()
6
5
  console.log('Base project path:', baseProjectPath)
6
+ const packageJson = await import(`${baseProjectPath}/package.json`, {
7
+ with: {
8
+ type: "json",
9
+ }
10
+ })
11
+ const { styleSheets } = packageJson
7
12
 
8
13
  // https://vitejs.dev/config/
9
14
  export default defineConfig({
@@ -16,9 +21,16 @@ export default defineConfig({
16
21
  }
17
22
  ]
18
23
  },
24
+ define: {
25
+ 'import.meta.env.BASE_PROJECT_PATH': JSON.stringify(baseProjectPath),
26
+ 'import.meta.env.STYLE_SHEETS': JSON.stringify(styleSheets)
27
+ },
19
28
  server: {
20
29
  fs: {
21
- allow: ['src', 'node_modules', baseProjectPath]
30
+ strict: false
22
31
  }
32
+ },
33
+ optimizeDeps: {
34
+ include: ['react', 'react-dom', 'react-dom/client', 'react/jsx-dev-runtime', 'react/jsx-runtime']
23
35
  }
24
36
  })