@constela/start 1.2.10 → 1.2.13

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.
@@ -2217,6 +2217,7 @@ import { join as join9, dirname as dirname5, relative as relative3, basename as
2217
2217
  import * as esbuild from "esbuild";
2218
2218
  import { existsSync as existsSync7 } from "fs";
2219
2219
  import { mkdir, readFile } from "fs/promises";
2220
+ import { createRequire } from "module";
2220
2221
  import { join as join8, dirname as dirname4, isAbsolute as isAbsolute2, relative as relative2 } from "path";
2221
2222
  import { fileURLToPath } from "url";
2222
2223
  var __dirname = dirname4(fileURLToPath(import.meta.url));
@@ -2250,6 +2251,7 @@ async function bundleRuntime(options) {
2250
2251
  async function bundleCSS(options) {
2251
2252
  const cssFiles = Array.isArray(options.css) ? options.css : [options.css];
2252
2253
  const outFile = join8(options.outDir, "_constela", "styles.css");
2254
+ const shouldMinify = options.minify ?? true;
2253
2255
  await mkdir(dirname4(outFile), { recursive: true });
2254
2256
  const resolvedCssFiles = cssFiles.map((f) => isAbsolute2(f) ? f : join8(process.cwd(), f));
2255
2257
  for (const fullPath of resolvedCssFiles) {
@@ -2258,50 +2260,64 @@ async function bundleCSS(options) {
2258
2260
  }
2259
2261
  }
2260
2262
  if (options.content !== void 0) {
2263
+ const firstCssFile = resolvedCssFiles[0];
2264
+ if (!firstCssFile) {
2265
+ throw new Error("No CSS files provided");
2266
+ }
2267
+ let cssContent;
2268
+ if (resolvedCssFiles.length === 1) {
2269
+ cssContent = await readFile(firstCssFile, "utf-8");
2270
+ } else {
2271
+ cssContent = resolvedCssFiles.map((f) => `@import "${f}";`).join("\n");
2272
+ }
2273
+ const require2 = createRequire(import.meta.url);
2261
2274
  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)
2275
+ const tailwindcssCssPath = require2.resolve("tailwindcss/index.css");
2276
+ cssContent = cssContent.replace(
2277
+ /@import\s+["']tailwindcss["']/g,
2278
+ `@import "${tailwindcssCssPath}"`
2279
+ );
2280
+ } catch {
2281
+ }
2282
+ if (options.content.length > 0) {
2283
+ const fg4 = (await import("fast-glob")).default;
2284
+ const resolvedContentPaths = options.content.map(
2285
+ (p) => isAbsolute2(p) ? p : join8(process.cwd(), p)
2286
+ );
2287
+ const matchedFiles = await fg4(resolvedContentPaths, { onlyFiles: true });
2288
+ if (matchedFiles.length === 0) {
2289
+ throw new Error(
2290
+ `No content files matched the provided patterns: ${options.content.join(", ")}`
2276
2291
  );
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
2292
  }
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;
2293
+ }
2294
+ const sourceDir = dirname4(firstCssFile);
2295
+ const sourceDirectives = options.content.map((contentPath) => {
2296
+ const absolutePath = isAbsolute2(contentPath) ? contentPath : join8(process.cwd(), contentPath);
2297
+ const srcPath = absolutePath.includes("*") ? dirname4(absolutePath.split("*")[0] ?? absolutePath) : absolutePath;
2298
+ const relativePath = relative2(sourceDir, srcPath);
2299
+ return `@source "${relativePath}";`;
2300
+ }).join("\n");
2301
+ const processedCssInput = sourceDirectives + "\n" + cssContent;
2302
+ const postcss = (await import("postcss")).default;
2303
+ let tailwindPostcss;
2304
+ try {
2305
+ tailwindPostcss = (await import("@tailwindcss/postcss")).default;
2306
+ } catch {
2307
+ throw new Error(
2308
+ "PostCSS processing requires @tailwindcss/postcss. Please install it: npm install @tailwindcss/postcss"
2309
+ );
2310
+ }
2311
+ try {
2296
2312
  const result = await postcss([
2297
2313
  tailwindPostcss({
2298
- base: baseDir,
2299
- optimize: options.minify ?? true
2314
+ // base determines where to look for source files and resolve paths
2315
+ base: sourceDir,
2316
+ optimize: shouldMinify
2300
2317
  })
2301
2318
  ]).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")
2319
+ // from must be the actual CSS file path for correct package resolution
2320
+ from: firstCssFile
2305
2321
  });
2306
2322
  await esbuild.build({
2307
2323
  stdin: {
@@ -2311,7 +2327,7 @@ async function bundleCSS(options) {
2311
2327
  },
2312
2328
  bundle: true,
2313
2329
  outfile: outFile,
2314
- minify: options.minify ?? true,
2330
+ minify: shouldMinify,
2315
2331
  conditions: ["style"]
2316
2332
  });
2317
2333
  } catch (error) {
@@ -2325,7 +2341,7 @@ async function bundleCSS(options) {
2325
2341
  entryPoints: resolvedCssFiles,
2326
2342
  bundle: true,
2327
2343
  outfile: outFile,
2328
- minify: options.minify ?? true,
2344
+ minify: shouldMinify,
2329
2345
  loader: { ".css": "css" },
2330
2346
  conditions: ["style"]
2331
2347
  });
@@ -2339,7 +2355,7 @@ async function bundleCSS(options) {
2339
2355
  },
2340
2356
  bundle: true,
2341
2357
  outfile: outFile,
2342
- minify: options.minify ?? true,
2358
+ minify: shouldMinify,
2343
2359
  conditions: ["style"]
2344
2360
  });
2345
2361
  }
@@ -2795,6 +2811,9 @@ async function resolveConfig(fileConfig, cliOptions) {
2795
2811
  }
2796
2812
  const result = { ...fileConfig };
2797
2813
  if (cliOptions.css !== void 0) result.css = cliOptions.css;
2814
+ if (cliOptions.cssContent !== void 0) {
2815
+ result.cssContent = cliOptions.cssContent.split(",").map((s) => s.trim()).filter(Boolean);
2816
+ }
2798
2817
  if (cliOptions.layoutsDir !== void 0) result.layoutsDir = cliOptions.layoutsDir;
2799
2818
  if (cliOptions.routesDir !== void 0) result.routesDir = cliOptions.routesDir;
2800
2819
  if (cliOptions.publicDir !== void 0) result.publicDir = cliOptions.publicDir;
@@ -11,6 +11,7 @@ type DevHandler = (options: {
11
11
  type BuildHandler = (options: {
12
12
  outDir?: string | undefined;
13
13
  css?: string | undefined;
14
+ cssContent?: string[] | undefined;
14
15
  layoutsDir?: string | undefined;
15
16
  }) => Promise<void>;
16
17
  type StartHandler = (options: {
package/dist/cli/index.js CHANGED
@@ -3,7 +3,7 @@ import {
3
3
  createDevServer,
4
4
  loadConfig,
5
5
  resolveConfig
6
- } from "../chunk-SC6WWHJ6.js";
6
+ } from "../chunk-O7RPEMZJ.js";
7
7
  import "../chunk-PUTC5BCP.js";
8
8
 
9
9
  // src/cli/index.ts
@@ -31,7 +31,8 @@ var buildHandler = async (options) => {
31
31
  await build({
32
32
  outDir: options.outDir,
33
33
  layoutsDir: options.layoutsDir,
34
- css: options.css
34
+ css: options.css,
35
+ cssContent: options.cssContent
35
36
  });
36
37
  console.log("Build complete");
37
38
  };
@@ -68,11 +69,12 @@ function createCLI() {
68
69
  program.command("dev").description("Start development server").option("-p, --port <port>", "Port number", "3000").option("-h, --host <host>", "Host address").option("-c, --css <path>", "CSS entry point for Vite processing").option("-l, --layoutsDir <path>", "Layouts directory for layout composition").action(async (options) => {
69
70
  await devHandler(options);
70
71
  });
71
- program.command("build").description("Build for production").option("-o, --outDir <outDir>", "Output directory").option("-c, --css <path>", "CSS entry point for Vite processing").option("-l, --layoutsDir <path>", "Layouts directory for layout composition").action(async (options) => {
72
+ program.command("build").description("Build for production").option("-o, --outDir <outDir>", "Output directory").option("-c, --css <path>", "CSS entry point for Vite processing").option("--cssContent <paths>", "Content paths for Tailwind CSS class scanning (comma-separated)").option("-l, --layoutsDir <path>", "Layouts directory for layout composition").action(async (options) => {
72
73
  const fileConfig = await loadConfig(process.cwd());
73
74
  const resolved = await resolveConfig(fileConfig, {
74
75
  outDir: options.outDir,
75
76
  css: options.css,
77
+ cssContent: options.cssContent,
76
78
  layoutsDir: options.layoutsDir
77
79
  });
78
80
  const mergedOptions = {};
@@ -80,6 +82,8 @@ function createCLI() {
80
82
  if (outDirValue !== void 0) mergedOptions.outDir = outDirValue;
81
83
  const cssValue = options.css ?? (typeof resolved.css === "string" ? resolved.css : resolved.css?.[0]);
82
84
  if (cssValue !== void 0) mergedOptions.css = cssValue;
85
+ const cssContentValue = resolved.cssContent;
86
+ if (cssContentValue !== void 0) mergedOptions.cssContent = cssContentValue;
83
87
  const layoutsDirValue = options.layoutsDir ?? resolved.layoutsDir;
84
88
  if (layoutsDirValue !== void 0) mergedOptions.layoutsDir = layoutsDirValue;
85
89
  await buildHandler(mergedOptions);
package/dist/index.d.ts CHANGED
@@ -526,6 +526,7 @@ declare class DataLoader {
526
526
 
527
527
  interface ConstelaConfigFile {
528
528
  css?: string | string[];
529
+ cssContent?: string[];
529
530
  layoutsDir?: string;
530
531
  routesDir?: string;
531
532
  publicDir?: string;
@@ -539,6 +540,7 @@ interface ConstelaConfigFile {
539
540
  }
540
541
  interface CLIOptions {
541
542
  css?: string | undefined;
543
+ cssContent?: string | undefined;
542
544
  layoutsDir?: string | undefined;
543
545
  routesDir?: string | undefined;
544
546
  publicDir?: string | undefined;
package/dist/index.js CHANGED
@@ -23,7 +23,7 @@ import {
23
23
  transformCsv,
24
24
  transformMdx,
25
25
  transformYaml
26
- } from "./chunk-SC6WWHJ6.js";
26
+ } from "./chunk-O7RPEMZJ.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.10",
3
+ "version": "1.2.13",
4
4
  "description": "Meta-framework for Constela applications",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",
@@ -44,10 +44,10 @@
44
44
  "@tailwindcss/postcss": "^4.0.0",
45
45
  "tailwindcss": "^4.0.0",
46
46
  "@constela/compiler": "0.7.0",
47
+ "@constela/core": "0.7.0",
47
48
  "@constela/router": "8.0.0",
48
- "@constela/server": "3.0.1",
49
49
  "@constela/runtime": "0.10.1",
50
- "@constela/core": "0.7.0"
50
+ "@constela/server": "3.0.1"
51
51
  },
52
52
  "devDependencies": {
53
53
  "@types/mdast": "^4.0.4",