bertui 0.3.1 → 0.3.2

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "bertui",
3
- "version": "0.3.1",
3
+ "version": "0.3.2",
4
4
  "description": "Lightning-fast React dev server powered by Bun and Elysia",
5
5
  "type": "module",
6
6
  "main": "./index.js",
@@ -10,6 +10,7 @@ export async function startDevServer(options = {}) {
10
10
  const port = parseInt(options.port) || 3000;
11
11
  const root = options.root || process.cwd();
12
12
  const compiledDir = join(root, '.bertui', 'compiled');
13
+ const stylesDir = join(root, '.bertui', 'styles');
13
14
 
14
15
  const config = await loadConfig(root);
15
16
 
@@ -49,6 +50,21 @@ export async function startDevServer(options = {}) {
49
50
  }
50
51
  }
51
52
 
53
+ // FIXED: Handle CSS files from .bertui/styles
54
+ if (path.startsWith('styles/') && path.endsWith('.css')) {
55
+ const cssPath = join(stylesDir, path.replace('styles/', ''));
56
+ const file = Bun.file(cssPath);
57
+
58
+ if (await file.exists()) {
59
+ return new Response(await file.text(), {
60
+ headers: {
61
+ 'Content-Type': 'text/css',
62
+ 'Cache-Control': 'no-store'
63
+ }
64
+ });
65
+ }
66
+ }
67
+
52
68
  if (path.startsWith('public/')) {
53
69
  const publicDir = join(root, 'public');
54
70
  const filepath = join(publicDir, path.replace('public/', ''));
@@ -132,6 +148,24 @@ ws.onclose = () => {
132
148
  });
133
149
  })
134
150
 
151
+ // FIXED: Serve CSS from .bertui/styles
152
+ .get('/styles/*', async ({ params, set }) => {
153
+ const filepath = join(stylesDir, params['*']);
154
+ const file = Bun.file(filepath);
155
+
156
+ if (!await file.exists()) {
157
+ set.status = 404;
158
+ return 'CSS file not found';
159
+ }
160
+
161
+ return new Response(await file.text(), {
162
+ headers: {
163
+ 'Content-Type': 'text/css',
164
+ 'Cache-Control': 'no-store'
165
+ }
166
+ });
167
+ })
168
+
135
169
  .get('/public/*', async ({ params, set }) => {
136
170
  const publicDir = join(root, 'public');
137
171
  const filepath = join(publicDir, params['*']);
@@ -165,6 +199,15 @@ ws.onclose = () => {
165
199
  function serveHTML(root, hasRouter, config) {
166
200
  const meta = config.meta || {};
167
201
 
202
+ // Find user's CSS files
203
+ const srcStylesDir = join(root, 'src', 'styles');
204
+ let userStylesheets = '';
205
+
206
+ if (existsSync(srcStylesDir)) {
207
+ const cssFiles = require('fs').readdirSync(srcStylesDir).filter(f => f.endsWith('.css'));
208
+ userStylesheets = cssFiles.map(f => ` <link rel="stylesheet" href="/styles/${f}">`).join('\n');
209
+ }
210
+
168
211
  const html = `
169
212
  <!DOCTYPE html>
170
213
  <html lang="${meta.lang || 'en'}">
@@ -184,6 +227,8 @@ function serveHTML(root, hasRouter, config) {
184
227
 
185
228
  <link rel="icon" type="image/svg+xml" href="/public/favicon.svg">
186
229
 
230
+ ${userStylesheets}
231
+
187
232
  <script type="importmap">
188
233
  {
189
234
  "imports": {