@homebound/truss 2.29.10 → 2.29.11
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/build/plugin/index.js +12 -8
- package/build/plugin/index.js.map +1 -1
- package/package.json +1 -1
- package/tsconfig.tsbuildinfo +1 -1
package/build/plugin/index.js
CHANGED
|
@@ -2586,16 +2586,18 @@ function parseTrussCss(cssText) {
|
|
|
2586
2586
|
}
|
|
2587
2587
|
return { rules, properties, arbitraryCssBlocks };
|
|
2588
2588
|
}
|
|
2589
|
-
function serializeTrussCss(css) {
|
|
2589
|
+
function serializeTrussCss(css, annotate = true) {
|
|
2590
2590
|
const lines = [];
|
|
2591
2591
|
for (const rule of css.rules) {
|
|
2592
|
-
lines.push(`/* @truss p:${rule.priority} c:${rule.className}
|
|
2592
|
+
if (annotate) lines.push(`/* @truss p:${rule.priority} c:${rule.className} */`);
|
|
2593
|
+
lines.push(rule.cssText);
|
|
2593
2594
|
}
|
|
2594
2595
|
for (const prop of css.properties) {
|
|
2595
|
-
lines.push(`/* @truss @property
|
|
2596
|
+
if (annotate) lines.push(`/* @truss @property */`);
|
|
2597
|
+
lines.push(prop.cssText);
|
|
2596
2598
|
}
|
|
2597
2599
|
for (const block of css.arbitraryCssBlocks) {
|
|
2598
|
-
lines.push(annotateArbitraryCssBlock(block.cssText));
|
|
2600
|
+
lines.push(annotate ? annotateArbitraryCssBlock(block.cssText) : block.cssText.trim());
|
|
2599
2601
|
}
|
|
2600
2602
|
return lines.join("\n");
|
|
2601
2603
|
}
|
|
@@ -3717,13 +3719,13 @@ function createTrussTransformSession(options) {
|
|
|
3717
3719
|
}
|
|
3718
3720
|
return result;
|
|
3719
3721
|
}
|
|
3720
|
-
function collectCss() {
|
|
3722
|
+
function collectCss(annotate = true) {
|
|
3721
3723
|
const mapping2 = ensureMapping();
|
|
3722
3724
|
const appCss = generateCssData(cssRegistry);
|
|
3723
3725
|
const allArbitrary = Array.from(arbitraryCssRegistry.entries()).sort((a, b) => compareClassNames(a[0], b[0])).map((entry) => entry[1]).join("\n\n");
|
|
3724
3726
|
if (allArbitrary.length > 0) appCss.arbitraryCssBlocks.push({ cssText: allArbitrary });
|
|
3725
3727
|
const libs = loadLibraries();
|
|
3726
|
-
const body = serializeTrussCss(libs.length === 0 ? appCss : mergeTrussCssData([...libs, appCss]));
|
|
3728
|
+
const body = serializeTrussCss(libs.length === 0 ? appCss : mergeTrussCssData([...libs, appCss]), annotate);
|
|
3727
3729
|
if (body.length === 0) return "";
|
|
3728
3730
|
return `${rootSpacingPreludeCss(mapping2.increment)}
|
|
3729
3731
|
${body}`;
|
|
@@ -3819,6 +3821,7 @@ function trussPlugin(opts) {
|
|
|
3819
3821
|
let debug = false;
|
|
3820
3822
|
let isTest = false;
|
|
3821
3823
|
let isBuild = false;
|
|
3824
|
+
let annotate = true;
|
|
3822
3825
|
let devSocket;
|
|
3823
3826
|
const libraryPaths = opts.libraries ?? [];
|
|
3824
3827
|
let emittedCssFileName = null;
|
|
@@ -3848,6 +3851,7 @@ function trussPlugin(opts) {
|
|
|
3848
3851
|
debug = config.command === "serve" || config.mode === "development" || config.mode === "test";
|
|
3849
3852
|
isTest = config.mode === "test";
|
|
3850
3853
|
isBuild = config.command === "build";
|
|
3854
|
+
annotate = !isBuild || Boolean(config.build?.lib);
|
|
3851
3855
|
},
|
|
3852
3856
|
buildStart() {
|
|
3853
3857
|
session.ensureMapping();
|
|
@@ -3861,7 +3865,7 @@ function trussPlugin(opts) {
|
|
|
3861
3865
|
devSocket = server.ws;
|
|
3862
3866
|
server.middlewares.use((req, res, next) => {
|
|
3863
3867
|
if (req.url !== VIRTUAL_CSS_ENDPOINT) return next();
|
|
3864
|
-
const css = session.collectCss();
|
|
3868
|
+
const css = session.collectCss(annotate);
|
|
3865
3869
|
res.setHeader("Content-Type", "text/css");
|
|
3866
3870
|
res.setHeader("Cache-Control", "no-store");
|
|
3867
3871
|
res.end(css);
|
|
@@ -3995,7 +3999,7 @@ import "${VIRTUAL_TEST_CSS_ID}";` : rewrittenImports.code;
|
|
|
3995
3999
|
// -- Production CSS emission --
|
|
3996
4000
|
generateBundle(_options, _bundle) {
|
|
3997
4001
|
if (!isBuild) return;
|
|
3998
|
-
const css = session.collectCss();
|
|
4002
|
+
const css = session.collectCss(annotate);
|
|
3999
4003
|
if (!css) return;
|
|
4000
4004
|
const hash = createHash("sha256").update(css).digest("hex").slice(0, 8);
|
|
4001
4005
|
const fileName = `assets/truss-${hash}.css`;
|