@constela/start 1.2.8 → 1.2.10

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.
@@ -2211,13 +2211,13 @@ h1 { color: #666; }
2211
2211
  // src/build/index.ts
2212
2212
  import { existsSync as existsSync8, readFileSync as readFileSync5 } from "fs";
2213
2213
  import { mkdir as mkdir2, writeFile, cp, readdir } from "fs/promises";
2214
- import { join as join9, dirname as dirname5, relative as relative2, basename as basename4, isAbsolute as isAbsolute3, resolve as resolve4 } from "path";
2214
+ import { join as join9, dirname as dirname5, relative as relative3, basename as basename4, isAbsolute as isAbsolute3, resolve as resolve4 } from "path";
2215
2215
 
2216
2216
  // src/build/bundler.ts
2217
2217
  import * as esbuild from "esbuild";
2218
2218
  import { existsSync as existsSync7 } from "fs";
2219
- import { mkdir } from "fs/promises";
2220
- import { join as join8, dirname as dirname4, isAbsolute as isAbsolute2 } from "path";
2219
+ import { mkdir, readFile } from "fs/promises";
2220
+ import { join as join8, dirname as dirname4, isAbsolute as isAbsolute2, relative as relative2 } from "path";
2221
2221
  import { fileURLToPath } from "url";
2222
2222
  var __dirname = dirname4(fileURLToPath(import.meta.url));
2223
2223
  async function bundleRuntime(options) {
@@ -2257,33 +2257,96 @@ async function bundleCSS(options) {
2257
2257
  throw new Error(`CSS file not found: ${fullPath}`);
2258
2258
  }
2259
2259
  }
2260
- try {
2261
- if (resolvedCssFiles.length === 1) {
2262
- await esbuild.build({
2263
- entryPoints: resolvedCssFiles,
2264
- bundle: true,
2265
- outfile: outFile,
2266
- minify: options.minify ?? true,
2267
- loader: { ".css": "css" },
2268
- conditions: ["style"]
2260
+ if (options.content !== void 0) {
2261
+ try {
2262
+ const firstCssFile = resolvedCssFiles[0];
2263
+ if (!firstCssFile) {
2264
+ throw new Error("No CSS files provided");
2265
+ }
2266
+ let cssContent;
2267
+ if (resolvedCssFiles.length === 1) {
2268
+ cssContent = await readFile(firstCssFile, "utf-8");
2269
+ } else {
2270
+ cssContent = resolvedCssFiles.map((f) => `@import "${f}";`).join("\n");
2271
+ }
2272
+ if (options.content.length > 0) {
2273
+ const fg4 = (await import("fast-glob")).default;
2274
+ const resolvedContentPaths = options.content.map(
2275
+ (p) => isAbsolute2(p) ? p : join8(process.cwd(), p)
2276
+ );
2277
+ const matchedFiles = await fg4(resolvedContentPaths, { onlyFiles: true });
2278
+ if (matchedFiles.length === 0) {
2279
+ throw new Error(
2280
+ `No content files matched the provided patterns: ${options.content.join(", ")}`
2281
+ );
2282
+ }
2283
+ }
2284
+ const sourceDir = dirname4(firstCssFile);
2285
+ const sourceDirectives = options.content.map((contentPath) => {
2286
+ const absolutePath = isAbsolute2(contentPath) ? contentPath : join8(process.cwd(), contentPath);
2287
+ const relativePath = relative2(sourceDir, absolutePath);
2288
+ return `@source "${relativePath}";`;
2289
+ }).join("\n");
2290
+ const processedCssInput = sourceDirectives + "\n" + cssContent;
2291
+ const postcss = (await import("postcss")).default;
2292
+ const tailwindPostcss = (await import("@tailwindcss/postcss")).default;
2293
+ const projectRoot = process.cwd();
2294
+ const isWithinProject = firstCssFile.startsWith(projectRoot);
2295
+ const baseDir = isWithinProject ? sourceDir : projectRoot;
2296
+ const result = await postcss([
2297
+ tailwindPostcss({
2298
+ base: baseDir,
2299
+ optimize: options.minify ?? true
2300
+ })
2301
+ ]).process(processedCssInput, {
2302
+ // Use a path within project root for package resolution
2303
+ // This ensures tailwindcss can be resolved from node_modules
2304
+ from: isWithinProject ? firstCssFile : join8(projectRoot, "styles.css")
2269
2305
  });
2270
- } else {
2271
- const virtualEntry = resolvedCssFiles.map((f) => `@import "${f}";`).join("\n");
2272
2306
  await esbuild.build({
2273
2307
  stdin: {
2274
- contents: virtualEntry,
2308
+ contents: result.css,
2275
2309
  loader: "css",
2276
- resolveDir: process.cwd()
2310
+ resolveDir: sourceDir
2277
2311
  },
2278
2312
  bundle: true,
2279
2313
  outfile: outFile,
2280
2314
  minify: options.minify ?? true,
2281
2315
  conditions: ["style"]
2282
2316
  });
2317
+ } catch (error) {
2318
+ const message = error instanceof Error ? error.message : String(error);
2319
+ throw new Error(`Failed to process CSS with PostCSS/Tailwind: ${message}`);
2320
+ }
2321
+ } else {
2322
+ try {
2323
+ if (resolvedCssFiles.length === 1) {
2324
+ await esbuild.build({
2325
+ entryPoints: resolvedCssFiles,
2326
+ bundle: true,
2327
+ outfile: outFile,
2328
+ minify: options.minify ?? true,
2329
+ loader: { ".css": "css" },
2330
+ conditions: ["style"]
2331
+ });
2332
+ } else {
2333
+ const virtualEntry = resolvedCssFiles.map((f) => `@import "${f}";`).join("\n");
2334
+ await esbuild.build({
2335
+ stdin: {
2336
+ contents: virtualEntry,
2337
+ loader: "css",
2338
+ resolveDir: process.cwd()
2339
+ },
2340
+ bundle: true,
2341
+ outfile: outFile,
2342
+ minify: options.minify ?? true,
2343
+ conditions: ["style"]
2344
+ });
2345
+ }
2346
+ } catch (error) {
2347
+ const message = error instanceof Error ? error.message : String(error);
2348
+ throw new Error(`Failed to bundle CSS to ${outFile}: ${message}`);
2283
2349
  }
2284
- } catch (error) {
2285
- const message = error instanceof Error ? error.message : String(error);
2286
- throw new Error(`Failed to bundle CSS to ${outFile}: ${message}`);
2287
2350
  }
2288
2351
  return "/_constela/styles.css";
2289
2352
  }
@@ -2632,14 +2695,15 @@ async function build2(options) {
2632
2695
  if (options?.css) {
2633
2696
  cssPath = await bundleCSS({
2634
2697
  outDir,
2635
- css: options.css
2698
+ css: options.css,
2699
+ ...options.cssContent ? { content: options.cssContent } : {}
2636
2700
  });
2637
2701
  }
2638
2702
  const absoluteRoutesDir = isAbsolute3(routesDir) ? routesDir : resolve4(routesDir);
2639
2703
  const projectRoot = dirname5(dirname5(absoluteRoutesDir));
2640
2704
  for (const route of jsonPages) {
2641
- const relPathFromRoutesDir = relative2(absoluteRoutesDir, route.file);
2642
- const relPathFromProjectRoot = relative2(projectRoot, route.file);
2705
+ const relPathFromRoutesDir = relative3(absoluteRoutesDir, route.file);
2706
+ const relPathFromProjectRoot = relative3(projectRoot, route.file);
2643
2707
  const content = readFileSync5(route.file, "utf-8");
2644
2708
  const page = validateJsonPage(content, route.file);
2645
2709
  if (isDynamicRoute(route.pattern)) {
package/dist/cli/index.js CHANGED
@@ -3,7 +3,7 @@ import {
3
3
  createDevServer,
4
4
  loadConfig,
5
5
  resolveConfig
6
- } from "../chunk-ZJMQ6IJY.js";
6
+ } from "../chunk-SC6WWHJ6.js";
7
7
  import "../chunk-PUTC5BCP.js";
8
8
 
9
9
  // src/cli/index.ts
package/dist/index.d.ts CHANGED
@@ -101,8 +101,10 @@ interface BuildOptions {
101
101
  routesDir?: string | undefined;
102
102
  publicDir?: string | undefined;
103
103
  layoutsDir?: string | undefined;
104
- /** CSS entry point(s) for Vite middleware processing */
104
+ /** CSS entry point(s) for bundling */
105
105
  css?: string | string[] | undefined;
106
+ /** Content paths for Tailwind CSS class scanning (enables PostCSS processing) */
107
+ cssContent?: string[] | undefined;
106
108
  target?: 'node' | 'edge' | undefined;
107
109
  }
108
110
 
package/dist/index.js CHANGED
@@ -23,7 +23,7 @@ import {
23
23
  transformCsv,
24
24
  transformMdx,
25
25
  transformYaml
26
- } from "./chunk-ZJMQ6IJY.js";
26
+ } from "./chunk-SC6WWHJ6.js";
27
27
  import {
28
28
  generateHydrationScript,
29
29
  renderPage,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@constela/start",
3
- "version": "1.2.8",
3
+ "version": "1.2.10",
4
4
  "description": "Meta-framework for Constela applications",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",
@@ -40,11 +40,14 @@
40
40
  "remark-parse": "^11.0.0",
41
41
  "unified": "^11.0.0",
42
42
  "vite": "^6.0.0",
43
+ "postcss": "^8.5.0",
44
+ "@tailwindcss/postcss": "^4.0.0",
45
+ "tailwindcss": "^4.0.0",
43
46
  "@constela/compiler": "0.7.0",
44
- "@constela/core": "0.7.0",
45
47
  "@constela/router": "8.0.0",
48
+ "@constela/server": "3.0.1",
46
49
  "@constela/runtime": "0.10.1",
47
- "@constela/server": "3.0.1"
50
+ "@constela/core": "0.7.0"
48
51
  },
49
52
  "devDependencies": {
50
53
  "@types/mdast": "^4.0.4",