observablehq / framework

A static site generator for data apps, dashboards, reports, and more. Observable Framework combines JavaScript on the front-end for interactive graphics with any language on the back-end for data analysis.
https://observablehq.com/framework/
ISC License
2.41k stars 111 forks source link

layered config #1396

Closed mbostock closed 4 months ago

mbostock commented 4 months ago

Alternative to #1392 which doesn’t require any Framework changes.

mythmon commented 4 months ago

I see! There is a bit of nuance here I wasn't appreciating before. To build the examples this way you'd do something this, right?

$ cd examples/responsive-iframe
$ npm run build -- --config ../observablehq.config.js

The one small gap I can see in this is that a fully general version would have to duplicate the JS/TS resolution logic, but that's not too bad.

mbostock commented 4 months ago

Yep, that’s right. Though we typically use Yarn.

yarn build --config ../observablehq.config.js

We don’t use a TypeScript config in any of the examples (yet), but even so, I don’t think we need to worry about the TS/JS resolution because TSX would automatically find the observablehq.config.ts if you try to import observablehq.config.js (assuming that you registered TSX as a loader, which doesn’t happen by default).

The automatic config watching also only watches the main config file, not the imported one. That’s fixable using node --watch, though.

I think both of these limitations are acceptable.

mbostock commented 4 months ago

This is ready. 👍