You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/getting-started.md
+1-1Lines changed: 1 addition & 1 deletion
Original file line number
Diff line number
Diff line change
@@ -209,7 +209,7 @@ Next, `cd` into your new project folder.
209
209
210
210
Framework’s local development server lets you preview your site in the browser as you make rapid changes. The preview server generates pages on-the-fly: as you edit files in your editor, changes are instantly streamed to your browser.
211
211
212
-
<divclass="tip">You can work offline with the preview server, but you must be connected to the internet to <ahref="./javascript/imports">import libraries</a> from npm. In the future, we intend to support self-hosting imported libraries; please upvote <ahref="https://github.com/observablehq/framework/issues/20">#20</a> and <ahref="https://github.com/observablehq/framework/issues/360">#360</a> if you are interested in this feature.</div>
212
+
<divclass="tip">You can develop offline, but you must connect to the internet to <ahref="./javascript/imports">import new libraries</a> from npm. Framework self-hosts imports: modules are downloaded from npm and stored in a local cache the first time you import them, and are included in <code>dist</code> when you build your project. In the future, we also plan to support importing from <code>node_modules</code>; please upvote <ahref="https://github.com/observablehq/framework/issues/360">#360</a> if you are interested in this feature.</div>
<div class="note">We’d also like to download imported modules from the CDN during build, making the built site entirely self-contained; see <a href="https://github.com/observablehq/framework/issues/20">#20</a>. This would further enable subresource integrity hashes; see <a href="https://github.com/observablehq/framework/issues/306">#306</a>.</div>
111
+
<div class="note">Framework automatically downloads <code>npm:</code> imports from npm during preview and build, making the built site entirely self-contained. If you prefer not to self-host a module, and instead load it from an external server at runtime, import a full URL instead of using the <code>npm:</code> protocol.</div>
Copy file name to clipboardExpand all lines: docs/routing.md
+8-8Lines changed: 8 additions & 8 deletions
Original file line number
Diff line number
Diff line change
@@ -157,14 +157,14 @@ The resulting output root is:
157
157
.
158
158
├─ dist
159
159
│ ├─ _import
160
-
│ │ └─ chart.js
160
+
│ │ └─ chart.c79c2048.js
161
161
│ ├─ _observablehq
162
162
│ │ └─ ... # additional assets for serving the site
163
163
│ └─ index.html
164
164
└─ ...
165
165
```
166
166
167
-
The import declaration is automatically rewritten during build to point to `./_import/chart.js` instead of `./chart.js`. (In the future [#260](https://github.com/observablehq/framework/issues/260), Observable Framework will add a content hash to the imported module name for cache-breaking.)
167
+
The import declaration is automatically rewritten during build to point to `./_import/chart.c79c2048.js` instead of `./chart.js`. The content hash `c79c2048` ensures cache-breaking during deploy, and allows assets to be marked as `cache-control: immutable` to improve performance.
168
168
169
169
Use a leading slash to denote paths relative to the source root, such as `/chart.js` instead of `./chart.js`. This allows you to use the same path to import a module from anywhere, even in nested folders. Observable Framework always generates relative links so that the generated site can be served under a base path.
170
170
@@ -186,18 +186,18 @@ Any files referenced by `FileAttachment` will automatically be copied to the `_f
186
186
.
187
187
├─ dist
188
188
│ ├─ _file
189
-
│ │ └─ quakes.csv
189
+
│ │ └─ quakes.e5f2eb94.csv
190
190
│ ├─ _observablehq
191
191
│ │ └─ ... # additional assets for serving the site
192
192
│ └─ index.html
193
193
└─ ...
194
194
```
195
195
196
-
`FileAttachment` references are automatically rewritten during build; for example, a reference to `quakes.csv` might be replaced with `_file/quakes.csv`. (In the future [#260](https://github.com/observablehq/framework/issues/260), Observable Framework will add a content hash to the attached file name for cache-breaking.) Only the files you reference statically are copied to the output root (`dist`), so nothing extra or unused is included in the built site.
196
+
`FileAttachment` references are automatically rewritten during build; for example, a reference to `quakes.csv` might be replaced with `_file/quakes.e5f2eb94.csv`. (As with imports, file names are given a content hash, here `e5f2eb94`, to improve performance.) Only the files you reference statically are copied to the output root (`dist`), so nothing extra or unused is included in the built site.
197
197
198
198
[Imported modules](#imports) can use `FileAttachment`, too. In this case, the path to the file is _relative to the importing module_ in the same fashion as `import`; this is accomplished by resolving relative paths at runtime with [`import.meta.url`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/import.meta).
199
199
200
-
Some additional assets are automatically promoted to file attachments and copied to `_file`. For example, if you have a `<link rel="stylesheet" href="style.css">` declared statically in a Markdown page, the `style.css` file will be copied to `_file`, too. The HTML elements eligible for file attachments are `audio`, `img`, `link`, `picture`, and `video`.
200
+
Some additional assets are automatically promoted to file attachments and copied to `_file`. For example, if you have a `<link rel="stylesheet" href="style.css">` declared statically in a Markdown page, the `style.css` file will be copied to `_file`, too (and the file name given a content hash). The HTML elements eligible for file attachments are `audio`, `img`, `link`, `picture`, and `video`.
201
201
202
202
## Data loaders
203
203
@@ -223,7 +223,7 @@ This will produce the following output root:
223
223
.
224
224
├─ dist
225
225
│ ├─ _file
226
-
│ │ └─ quakes.json
226
+
│ │ └─ quakes.99da78d9.json
227
227
│ ├─ _observablehq
228
228
│ │ └─ ... # additional assets for serving the site
229
229
│ └─ index.html
@@ -240,7 +240,7 @@ File attachments can be also be pulled from archives. The following archive exte
240
240
-`.tar` - for [tarballs](<https://en.wikipedia.org/wiki/Tar_(computing)>)
241
241
-`.tar.gz` and `.tgz` - for [compressed tarballs](https://en.wikipedia.org/wiki/Gzip)
242
242
243
-
For example, say you have a `quakes.zip` archive that includes yearly files for observed earthquakes. If you reference `FileAttachment("quakes/2021.csv")` in code, Observable Framework will pull the `2021.csv` from `quakes.zip`. So this source root:
243
+
For example, say you have a `quakes.zip` archive that includes yearly files for observed earthquakes. If you reference `FileAttachment("quakes/2021.csv")`, Framework will pull the `2021.csv` from `quakes.zip`. So this source root:
244
244
245
245
```ini
246
246
.
@@ -257,7 +257,7 @@ Becomes this output:
257
257
├─ dist
258
258
│ ├─ _file
259
259
│ │ └─ quakes
260
-
│ │ └─ 2021.csv
260
+
│ │ └─ 2021.e5f2eb94.csv
261
261
│ ├─ _observablehq
262
262
│ │ └─ ... # additional assets for serving the site
0 commit comments