EHS-Studio Claude Sonnet 5.5 commited on
Commit
6c00f0c
·
1 Parent(s): 26eb6e7

build: --map-name, because Vercel refuses to serve *.map; the site's map is site.css.sourcemap

Browse files
Files changed (4) hide show
  1. .gitignore +1 -1
  2. GUIDE.md +2 -1
  3. cli/dssl.mjs +5 -3
  4. scripts/build-site-css.mjs +1 -1
.gitignore CHANGED
@@ -64,7 +64,7 @@ mini-services/
64
 
65
  # compiled from public/styles by scripts/build-site-css.mjs
66
  /public/site.css
67
- /public/site.css.map
68
 
69
  # real-editor test scratch (scripts/test-in-editor.mjs)
70
  /.vsc-test/
 
64
 
65
  # compiled from public/styles by scripts/build-site-css.mjs
66
  /public/site.css
67
+ /public/site.css.sourcemap
68
 
69
  # real-editor test scratch (scripts/test-in-editor.mjs)
70
  /.vsc-test/
GUIDE.md CHANGED
@@ -822,7 +822,8 @@ them is still fully styled without it, it just does not move.
822
  and asserts the browser reports zero violations.
823
  - *Devtools.* `--sourcemap` writes `site.css.map` with a mapping for every rule and every declaration, and embeds the .dssl
824
  source so it works even when the file is not served. Chrome's own DevTools then shows `card.dssl:4` next to a rule in the
825
- Styles pane and opens the source on click. The selectors come out wrapped in `:where()`, so DevTools shows `:where(.card)`.
 
826
  The engine's inline styles have no source to point at (a style attribute cannot carry one), so for a runtime page use
827
  `DSSL.inspect()`.
828
 
 
822
  and asserts the browser reports zero violations.
823
  - *Devtools.* `--sourcemap` writes `site.css.map` with a mapping for every rule and every declaration, and embeds the .dssl
824
  source so it works even when the file is not served. Chrome's own DevTools then shows `card.dssl:4` next to a rule in the
825
+ Styles pane and opens the source on click. The selectors come out wrapped in `:where()`, so DevTools shows `:where(.card)`. Some hosts refuse to serve a file ending in `.map`
826
+ (Vercel answers 403, which this site found out the hard way); `--map-name site.css.sourcemap` writes the same map under another name.
827
  The engine's inline styles have no source to point at (a style attribute cannot carry one), so for a runtime page use
828
  `DSSL.inspect()`.
829
 
cli/dssl.mjs CHANGED
@@ -52,6 +52,7 @@ const USAGE = `dssl v${VERSION} - the DSSL style language
52
  dssl build <files…> compile the static subset to a real .css file (several files: in load order, tokens first)
53
  -o <out.css> output path (default: <first file>.css)
54
  --sourcemap write <out.css>.map so devtools show the .dssl file and line of each rule
 
55
  --reset include the small reset, as a layer that loses to everything
56
  --inline-tokens write each token's value in place of var(--dssl-x) where the token is defined once and
57
  never changed: the fastest CSS, but a token changed at run time will not reach it
@@ -204,6 +205,7 @@ if (cmd === 'dev') {
204
  const inlineTokens = args.includes('--inline-tokens');
205
  for (const f of ['--json', '--no-banner', '--strict', '--sourcemap', '--reset', '--native-specificity', '--inline-tokens']) { const i = args.indexOf(f); if (i !== -1) args.splice(i, 1); }
206
  const outPath = readArg(args, '-o') || readArg(args, '--out');
 
207
  if (!args.length) { console.error('dssl build: give me a .dssl file to build (or several, in load order: tokens first)'); process.exit(2); }
208
  const inputs = [...args];
209
  const results = compileAll(inputs);
@@ -214,7 +216,7 @@ if (cmd === 'dev') {
214
  for (const x of results) sources[x.name] = { path: pathRelative(outDir, pathResolve(x.file)).split('\\').join('/'), content: readFileSync(x.file, 'utf8') };
215
  const built = toCSS(results.map((x) => x.doc), {
216
  file: inputs.map((f) => basename(f)).join(' + '), banner, version: VERSION, reset, nativeSpecificity, inlineTokens,
217
- sourceMap: sourcemap, sources, mapFile: basename(outputPath), sourceMapUrl: sourcemap ? basename(outputPath) + '.map' : undefined,
218
  });
219
  if (json) {
220
  console.log(JSON.stringify({
@@ -229,12 +231,12 @@ if (cmd === 'dev') {
229
  }, null, 2));
230
  } else {
231
  writeFileSync(outputPath, built.css);
232
- if (built.map) writeFileSync(outputPath + '.map', JSON.stringify(built.map));
233
  const rep = built.report;
234
  console.log(`built ${outputPath} from ${results.map((x) => x.file).join(', ')}`);
235
  console.log(` ${rep.rules} rule(s), ${rep.shadowRules} pseudo-element rule(s), ${rep.keyframes} @keyframes, ${rep.raws} raw block(s)`);
236
  if (rep.layers.length) console.log(` layers: ${rep.layers.join(' < ')}`);
237
- if (built.map) console.log(` source map: ${outputPath}.map (browser devtools show the .dssl file and line for each rule)`);
238
  if (rep.seenStripped) console.log(` ${rep.seenStripped} seen rule(s) applied unconditionally (the no-JS state)`);
239
  if (rep.bakedTextures) console.log(` ${rep.bakedTextures} texture(s) baked into the CSS as background images`);
240
  for (const n of rep.notBaked || []) console.log(` texture on "${n.sel}" stays in the runtime: ${n.why}`);
 
52
  dssl build <files…> compile the static subset to a real .css file (several files: in load order, tokens first)
53
  -o <out.css> output path (default: <first file>.css)
54
  --sourcemap write <out.css>.map so devtools show the .dssl file and line of each rule
55
+ --map-name <f> file name for the map when your host will not serve *.map (default <out.css>.map)
56
  --reset include the small reset, as a layer that loses to everything
57
  --inline-tokens write each token's value in place of var(--dssl-x) where the token is defined once and
58
  never changed: the fastest CSS, but a token changed at run time will not reach it
 
205
  const inlineTokens = args.includes('--inline-tokens');
206
  for (const f of ['--json', '--no-banner', '--strict', '--sourcemap', '--reset', '--native-specificity', '--inline-tokens']) { const i = args.indexOf(f); if (i !== -1) args.splice(i, 1); }
207
  const outPath = readArg(args, '-o') || readArg(args, '--out');
208
+ const mapName = readArg(args, '--map-name'); // some hosts refuse to serve *.map; a different name is the same map
209
  if (!args.length) { console.error('dssl build: give me a .dssl file to build (or several, in load order: tokens first)'); process.exit(2); }
210
  const inputs = [...args];
211
  const results = compileAll(inputs);
 
216
  for (const x of results) sources[x.name] = { path: pathRelative(outDir, pathResolve(x.file)).split('\\').join('/'), content: readFileSync(x.file, 'utf8') };
217
  const built = toCSS(results.map((x) => x.doc), {
218
  file: inputs.map((f) => basename(f)).join(' + '), banner, version: VERSION, reset, nativeSpecificity, inlineTokens,
219
+ sourceMap: sourcemap, sources, mapFile: basename(outputPath), sourceMapUrl: sourcemap ? (mapName || basename(outputPath) + '.map') : undefined,
220
  });
221
  if (json) {
222
  console.log(JSON.stringify({
 
231
  }, null, 2));
232
  } else {
233
  writeFileSync(outputPath, built.css);
234
+ if (built.map) writeFileSync(mapName ? join(dirname(outputPath), mapName) : outputPath + '.map', JSON.stringify(built.map));
235
  const rep = built.report;
236
  console.log(`built ${outputPath} from ${results.map((x) => x.file).join(', ')}`);
237
  console.log(` ${rep.rules} rule(s), ${rep.shadowRules} pseudo-element rule(s), ${rep.keyframes} @keyframes, ${rep.raws} raw block(s)`);
238
  if (rep.layers.length) console.log(` layers: ${rep.layers.join(' < ')}`);
239
+ if (built.map) console.log(` source map: ${mapName ? join(dirname(outputPath), mapName) : outputPath + '.map'} (browser devtools show the .dssl file and line for each rule)`);
240
  if (rep.seenStripped) console.log(` ${rep.seenStripped} seen rule(s) applied unconditionally (the no-JS state)`);
241
  if (rep.bakedTextures) console.log(` ${rep.bakedTextures} texture(s) baked into the CSS as background images`);
242
  for (const n of rep.notBaked || []) console.log(` texture on "${n.sel}" stays in the runtime: ${n.why}`);
scripts/build-site-css.mjs CHANGED
@@ -13,6 +13,6 @@ import { fileURLToPath } from 'node:url';
13
  const root = path.resolve(path.dirname(fileURLToPath(import.meta.url)), '..');
14
  const SHEETS = ['tokens', 'site', 'home', 'docs', 'playground', 'changelog', 'bench']; // the order the page loads them in
15
  mkdirSync(path.join(root, 'public'), { recursive: true });
16
- const r = spawnSync(process.execPath, ['--no-warnings', path.join(root, 'cli/dssl.mjs'), 'build', ...SHEETS.map((s) => path.join('public/styles', s + '.dssl')), '-o', 'public/site.css', '--reset', '--sourcemap', '--no-banner'], { cwd: root, encoding: 'utf8' });
17
  process.stdout.write(r.stdout); process.stderr.write(r.stderr);
18
  process.exit(r.status || 0);
 
13
  const root = path.resolve(path.dirname(fileURLToPath(import.meta.url)), '..');
14
  const SHEETS = ['tokens', 'site', 'home', 'docs', 'playground', 'changelog', 'bench']; // the order the page loads them in
15
  mkdirSync(path.join(root, 'public'), { recursive: true });
16
+ const r = spawnSync(process.execPath, ['--no-warnings', path.join(root, 'cli/dssl.mjs'), 'build', ...SHEETS.map((s) => path.join('public/styles', s + '.dssl')), '-o', 'public/site.css', '--reset', '--sourcemap', '--map-name', 'site.css.sourcemap', '--no-banner'], { cwd: root, encoding: 'utf8' });
17
  process.stdout.write(r.stdout); process.stderr.write(r.stderr);
18
  process.exit(r.status || 0);