@constela/start 1.2.8 → 1.2.9
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/dist/{chunk-ZJMQ6IJY.js → chunk-APCF5VWN.js} +82 -22
- package/dist/cli/index.js +1 -1
- package/dist/index.d.ts +3 -1
- package/dist/index.js +1 -1
- package/package.json +6 -3
|
@@ -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
|
|
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,92 @@ async function bundleCSS(options) {
|
|
|
2257
2257
|
throw new Error(`CSS file not found: ${fullPath}`);
|
|
2258
2258
|
}
|
|
2259
2259
|
}
|
|
2260
|
-
|
|
2261
|
-
|
|
2262
|
-
|
|
2263
|
-
|
|
2264
|
-
|
|
2265
|
-
|
|
2266
|
-
|
|
2267
|
-
|
|
2268
|
-
|
|
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 result = await postcss([
|
|
2294
|
+
tailwindPostcss({
|
|
2295
|
+
base: sourceDir,
|
|
2296
|
+
optimize: options.minify ?? true
|
|
2297
|
+
})
|
|
2298
|
+
]).process(processedCssInput, {
|
|
2299
|
+
// Use __dirname for package resolution (tailwindcss is a peer dependency of this package)
|
|
2300
|
+
from: join8(__dirname, "styles.css")
|
|
2269
2301
|
});
|
|
2270
|
-
} else {
|
|
2271
|
-
const virtualEntry = resolvedCssFiles.map((f) => `@import "${f}";`).join("\n");
|
|
2272
2302
|
await esbuild.build({
|
|
2273
2303
|
stdin: {
|
|
2274
|
-
contents:
|
|
2304
|
+
contents: result.css,
|
|
2275
2305
|
loader: "css",
|
|
2276
|
-
resolveDir:
|
|
2306
|
+
resolveDir: sourceDir
|
|
2277
2307
|
},
|
|
2278
2308
|
bundle: true,
|
|
2279
2309
|
outfile: outFile,
|
|
2280
2310
|
minify: options.minify ?? true,
|
|
2281
2311
|
conditions: ["style"]
|
|
2282
2312
|
});
|
|
2313
|
+
} catch (error) {
|
|
2314
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
2315
|
+
throw new Error(`Failed to process CSS with PostCSS/Tailwind: ${message}`);
|
|
2316
|
+
}
|
|
2317
|
+
} else {
|
|
2318
|
+
try {
|
|
2319
|
+
if (resolvedCssFiles.length === 1) {
|
|
2320
|
+
await esbuild.build({
|
|
2321
|
+
entryPoints: resolvedCssFiles,
|
|
2322
|
+
bundle: true,
|
|
2323
|
+
outfile: outFile,
|
|
2324
|
+
minify: options.minify ?? true,
|
|
2325
|
+
loader: { ".css": "css" },
|
|
2326
|
+
conditions: ["style"]
|
|
2327
|
+
});
|
|
2328
|
+
} else {
|
|
2329
|
+
const virtualEntry = resolvedCssFiles.map((f) => `@import "${f}";`).join("\n");
|
|
2330
|
+
await esbuild.build({
|
|
2331
|
+
stdin: {
|
|
2332
|
+
contents: virtualEntry,
|
|
2333
|
+
loader: "css",
|
|
2334
|
+
resolveDir: process.cwd()
|
|
2335
|
+
},
|
|
2336
|
+
bundle: true,
|
|
2337
|
+
outfile: outFile,
|
|
2338
|
+
minify: options.minify ?? true,
|
|
2339
|
+
conditions: ["style"]
|
|
2340
|
+
});
|
|
2341
|
+
}
|
|
2342
|
+
} catch (error) {
|
|
2343
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
2344
|
+
throw new Error(`Failed to bundle CSS to ${outFile}: ${message}`);
|
|
2283
2345
|
}
|
|
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
2346
|
}
|
|
2288
2347
|
return "/_constela/styles.css";
|
|
2289
2348
|
}
|
|
@@ -2632,14 +2691,15 @@ async function build2(options) {
|
|
|
2632
2691
|
if (options?.css) {
|
|
2633
2692
|
cssPath = await bundleCSS({
|
|
2634
2693
|
outDir,
|
|
2635
|
-
css: options.css
|
|
2694
|
+
css: options.css,
|
|
2695
|
+
...options.cssContent ? { content: options.cssContent } : {}
|
|
2636
2696
|
});
|
|
2637
2697
|
}
|
|
2638
2698
|
const absoluteRoutesDir = isAbsolute3(routesDir) ? routesDir : resolve4(routesDir);
|
|
2639
2699
|
const projectRoot = dirname5(dirname5(absoluteRoutesDir));
|
|
2640
2700
|
for (const route of jsonPages) {
|
|
2641
|
-
const relPathFromRoutesDir =
|
|
2642
|
-
const relPathFromProjectRoot =
|
|
2701
|
+
const relPathFromRoutesDir = relative3(absoluteRoutesDir, route.file);
|
|
2702
|
+
const relPathFromProjectRoot = relative3(projectRoot, route.file);
|
|
2643
2703
|
const content = readFileSync5(route.file, "utf-8");
|
|
2644
2704
|
const page = validateJsonPage(content, route.file);
|
|
2645
2705
|
if (isDynamicRoute(route.pattern)) {
|
package/dist/cli/index.js
CHANGED
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
|
|
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
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@constela/start",
|
|
3
|
-
"version": "1.2.
|
|
3
|
+
"version": "1.2.9",
|
|
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",
|
|
47
|
+
"@constela/server": "3.0.1",
|
|
44
48
|
"@constela/core": "0.7.0",
|
|
45
|
-
"@constela/router": "8.0.0",
|
|
46
49
|
"@constela/runtime": "0.10.1",
|
|
47
|
-
"@constela/
|
|
50
|
+
"@constela/router": "8.0.0"
|
|
48
51
|
},
|
|
49
52
|
"devDependencies": {
|
|
50
53
|
"@types/mdast": "^4.0.4",
|