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
{{ message }}
Repository navigation
Commit 3c6a771
Browse filesBrowse the repository at this point in the historyBrowse files
$build.outdir and --outdir (-o) name the output folder, so a site that
merges bongo's output with other tools' files can keep them apart.
The config now loads before the output folder is touched. A config that
fails to load empties only the --outdir folder or the folder of the
last good build, never a guessed one. dev --write follows the config.
Copy file name to clipboardExpand all lines: docs/content/cli.md
+17-12Lines changed: 17 additions & 12 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -5,7 +5,7 @@ group: Start
5
5
order: 4
6
6
---
7
7
8
-
The `bongo` command has two subcommands. `bongo build` writes the site to `public/`. `bongo dev` serves the site and rebuilds it when a file changes.
8
+
The `bongo` command has two subcommands. `bongo build` writes the site to the [output folder](#output-folder), `public/` by default. `bongo dev` serves the site and rebuilds it when a file changes.
9
9
10
10
## Commands
11
11
@@ -16,30 +16,32 @@ bongo dev
16
16
17
17
| Command | Description |
18
18
| --- | --- |
19
-
|`bongo build`| Build the site into `public/`. |
19
+
|`bongo build`| Build the site into the output folder. |
20
20
|`bongo dev`| Start the dev server, build the site behind it, and rebuild on each change. See [Dev server](/dev-server/). |
21
21
22
-
When it is done, `bongo build` prints the size of each file in `public/`, and its gzip size. Above 50 files, it prints the total size of each kind of file instead, such as `.html` or `.png`, and lists only the scripts and stylesheets, with their gzip sizes.
22
+
When it is done, `bongo build` prints the size of each file in the output folder, and its gzip size. Above 50 files, it prints the total size of each kind of file instead, such as `.html` or `.png`, and lists only the scripts and stylesheets, with their gzip sizes.
23
23
24
24
## Options
25
25
26
26
```sh
27
27
bongo build -C site --minify
28
28
bongo dev -C site --host --port 3000
29
29
bongo dev --write
30
+
bongo build --outdir web/public
30
31
bongo build --debug
31
32
bongo build --fresh
32
33
bongo build --drafts
33
34
```
34
35
35
36
| Option | Default | Description |
36
37
| --- | --- | --- |
37
-
|`-C`, `--cwd`|`.`| The project folder. bongo finds the config, the source folders, and `public/` in it. |
38
+
|`-C`, `--cwd`|`.`| The project folder. bongo finds the config and the source folders in it. |
38
39
|`-H`, `--host`|`localhost`| The host that `bongo dev` binds. A bare `--host`, with no value, exposes the server on your network. |
39
40
|`-p`, `--port`|`3000`| The port that `bongo dev` binds. |
41
+
|`-o`, `--outdir`|`public`| The folder to write the site to, from the project folder. It wins over [`$build.outdir`](/config/#output-folder). See [Output folder](#output-folder). |
40
42
|`-m`, `--minify`| off | Minify the output. See [Minify](#minify). |
41
43
|`-d`, `--debug`| off | Log each build stage and its time. See [Debug](#debug). |
42
-
|`-w`, `--write`| off |`bongo dev` only. Also write the output to `public/`. See [Output folder](#output-folder). |
44
+
|`-w`, `--write`| off |`bongo dev` only. Also write the output to the output folder. See [Output folder](#output-folder). |
43
45
|`-f`, `--fresh`| off | Render every page, not only the pages that a change reaches. See [Incremental builds](#incremental-builds). |
44
46
|`--drafts`| off; on for `bongo dev`| Build drafts: pages with `draft: true`, or a `date` after the build starts. `--no-drafts` leaves them out. See [Drafts](/content/#drafts). |
45
47
|`-v`, `--version`|| Show the version. |
@@ -79,13 +81,15 @@ Without `--debug`, a stage that is still running after 15 seconds prints `still
79
81
80
82
## Output folder
81
83
82
-
`bongo build` writes over the files that an earlier run left in `public/`, which is much faster than making them again. When it is done, it deletes each file of the last build that it did not write, so no file from an earlier run stays. The record of the last build lists those files, so `bongo build` does not list `public/`. Thus a file that something else put in `public/` stays, until a build without the record, such as `bongo build --fresh`, lists the folder and deletes it. When the build fails, it empties `public/` and deletes the record, so no part of the failed build stays.
84
+
The output folder is `public/` in the project folder. To use another folder, set [`$build.outdir`](/config/#output-folder) in the config, or pass `--outdir`. The flag wins over the config. bongo owns this folder, so do not let another tool write its files there. When the site also needs files from other tools, such as maps or API docs, build to a folder of its own, such as `web/public`, and copy the folders together in your deploy step.
83
85
84
-
`bongo dev` does not use `public/`. It keeps its output in memory and serves it from there. Thus a `bongo build` that runs at the same time never changes what dev serves, and dev never changes what the build writes.
86
+
`bongo build` writes over the files that an earlier run left in the output folder, which is much faster than making them again. When it is done, it deletes each file of the last build that it did not write, so no file from an earlier run stays. The record of the last build lists those files, so `bongo build`does not list the folder. Thus a file that something else put in the folder stays, until a build without the record, such as `bongo build --fresh`, lists the folder and deletes it. When the build fails, it empties the output folder and deletes the record, so no part of the failed build stays. A config that fails to load cannot name `$build.outdir`. Then bongo empties the `--outdir` folder, or else the folder of the last good build, and no other folder.
85
87
86
-
With `--write`, `bongo dev`also writes its output to `public/`. It empties the folder before the first build. After that, each rebuild deletes only the files that the new build no longer writes.
88
+
`bongo dev`does not use the output folder. It keeps its output in memory and serves it from there. Thus a `bongo build` that runs at the same time never changes what dev serves, and dev never changes what the build writes.
87
89
88
-
bongo never follows a symlink in `public/`. It deletes a symlink that a write or a deletion goes through, and a build that lists the folder deletes each symlink in it. It never deletes the file or folder that a symlink points to. bongo refuses to empty or write over `public/`, and the build fails, when the folder resolves through symlinks to:
90
+
With `--write`, `bongo dev` also writes its output to the output folder. It empties the folder before the first build. After that, each rebuild deletes only the files that the new build no longer writes. When the config names another `$build.outdir`, dev empties the new folder and writes all of its output there.
91
+
92
+
bongo never follows a symlink in the output folder. It deletes a symlink that a write or a deletion goes through, and a build that lists the folder deletes each symlink in it. It never deletes the file or folder that a symlink points to. bongo refuses to empty or write over the output folder, and the build fails, when the folder resolves through symlinks to:
89
93
90
94
- the project root, or a folder above it,
91
95
- a folder outside the project,
@@ -106,7 +110,7 @@ Each build compares the size and the mtime of each source file with the record.
106
110
- a script, a stylesheet, an image, or another asset that it links changes, or a module or stylesheet that one of them imports, since the name of the output file changes. `bongo dev` names each script and stylesheet by its entry, not by its content. There, an edit to one renders only the pages that inline it or use its CSS module classes. The other pages reload and get the new file,
107
111
- the config has `$hooks.transform`, and an output file is added, deleted, or changes its frontmatter, since the hook gets the list of output files,
108
112
- it was a draft by its `date`, and that moment has passed,
109
-
- its file in `public/` changed or is gone since the last build.
113
+
- its file in the output folder changed or is gone since the last build.
110
114
111
115
Every page renders again when the config changes, or a local file that it imports, a file in `data/`, `layouts/`, or `partials/`, the lockfile, the version of bongo, the runtime, `NODE_ENV`, `--minify`, or `--drafts`. [Output files](/output-files/) and [data modules](/data-modules/) render on every build, since they can read every page.
112
116
@@ -116,7 +120,7 @@ bongo cannot see a change that keeps the size and the mtime of a source file, as
116
120
bongo build --fresh
117
121
```
118
122
119
-
A build that fails empties `public/`, so the next build renders every page. To start over, delete `node_modules/.cache/bongo/memo.json`, or use `--fresh`.
123
+
A build that fails empties the output folder, so the next build renders every page. To start over, delete `node_modules/.cache/bongo/memo.json`, or use `--fresh`.
`dev(options)` starts the dev server, as `bongo dev` does. It resolves after the first build, and the server keeps running. It takes `cwd`, `debug`, `drafts`, `fresh`, `port`, `host`, and `write`, the same as the `bongo dev` options:
150
+
`dev(options)` starts the dev server, as `bongo dev` does. It resolves after the first build, and the server keeps running. It takes `cwd`, `debug`, `drafts`, `fresh`, `outdir`, `port`, `host`, and `write`, the same as the `bongo dev` options:
The `--outdir` flag wins over it. bongo deletes each file in this folder that the build does not write, so keep the files of other tools in another folder. See [Output folder](/cli/#output-folder) for the rules.
271
+
257
272
## Plugins
258
273
259
274
A plugin is a partial config object. Plugins usually come from a function, such as `markdown()` from [@bongo/markdown](/markdown/) or `feed()` from [@bongo/feed](/feed/):
Copy file name to clipboardExpand all lines: docs/content/dev-server.md
+2-2Lines changed: 2 additions & 2 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -36,9 +36,9 @@ If the config or a data file fails to load, the error overlay shows the error, a
36
36
37
37
## Output in memory
38
38
39
-
The dev server keeps each build in memory and serves it from there, as Vite does. It does not read or write `public/`. Thus you can run `bongo build` while `bongo dev` runs: neither one changes the output of the other.
39
+
The dev server keeps each build in memory and serves it from there, as Vite does. It does not read or write the output folder. Thus you can run `bongo build` while `bongo dev` runs: neither one changes the output of the other.
40
40
41
-
To see the dev output as files, run `bongo dev --write`. Then dev also writes its output to `public/`. See [Output folder](/cli/#output-folder).
41
+
To see the dev output as files, run `bongo dev --write`. Then dev also writes its output to the output folder, `public/` by default. See [Output folder](/cli/#output-folder).
42
42
43
43
The dev server serves a file that bongo only copies from `content/`, such as a PDF, from its source. Thus an edit to it shows at once.
Copy file name to clipboardExpand all lines: docs/content/project.md
+5-5Lines changed: 5 additions & 5 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -27,7 +27,7 @@ my-site/
27
27
|`data/`| Holds JSON, YAML, and module files. Templates get them as `$data`. |
28
28
|`layouts/`| Holds the `.hbs` layouts that wrap pages. |
29
29
|`partials/`| Holds the `.hbs`, JavaScript, and TypeScript partials. |
30
-
|`public/`| Receives the output of `bongo build`. Each build writes over it, then deletes the files of the last build that it did not write. `bongo dev` keeps its output in memory. |
30
+
|`public/`| Receives the output of `bongo build`, unless [`$build.outdir`](/config/#output-folder) names another folder. Each build writes over it, then deletes the files of the last build that it did not write. `bongo dev` keeps its output in memory. |
31
31
|`bongo.config.ts`| The config. |
32
32
33
33
### `assets/`
@@ -50,7 +50,7 @@ A partial is a template that layouts, `.hbs` content, and Markdown can call by n
50
50
51
51
### `public/`
52
52
53
-
`bongo build` writes over `public/`, then deletes each file of the last build that it did not write. `bongo dev` keeps its output in memory and does not touch `public/`, unless you pass `--write`. bongo refuses to use the folder when it is not a safe folder. See [Output folder](/cli/#output-folder).
53
+
The output folder. [`$build.outdir`](/config/#output-folder) or `--outdir` can name another folder. `bongo build` writes over it, then deletes each file of the last build that it did not write. `bongo dev` keeps its output in memory and does not touch the folder, unless you pass `--write`. bongo refuses to use the folder when it is not a safe folder. See [Output folder](/cli/#output-folder).
54
54
55
55
### `bongo.config.ts`
56
56
@@ -60,10 +60,10 @@ The config can also be `bongo.config.mjs`, `bongo.config.cjs`, or `bongo.config.
60
60
61
61
When you run `bongo build`, bongo does these steps:
62
62
63
-
1.`bongo build` keeps the files of the last build in `public/` to write over them. The [record of the last build](/cli/#incremental-builds) lists them; without it, bongo lists the folder and deletes each symlink in it. Then bongo loads the config, `bongo.config.{ts,mjs,cjs,js}`. Rolldown bundles the config and the local files that it imports into one temporary `.mjs` module. bongo imports that module, then deletes it. This works the same in Bun, Deno, and Node. Packages stay external and resolve as usual. A package linked into `node_modules` from outside it, such as a workspace package, is local code: bongo bundles it too, and the packages it imports resolve from its own folder. `import.meta.url`, `import.meta.dirname`, and `__dirname` keep pointing at each source file. TypeScript partials, `data/` modules, and [data modules](/data-modules/) load the same way.
64
-
2.It loads the files in `data/` as `$data`. It collects layouts from `layouts/` and partials from `partials/`. It compiles the Handlebars files (`.hbs`) with tempura, and loads the JavaScript and TypeScript partials as modules.
63
+
1. bongo loads the config, `bongo.config.{ts,mjs,cjs,js}`. Rolldown bundles the config and the local files that it imports into one temporary `.mjs` module. bongo imports that module, then deletes it. This works the same in Bun, Deno, and Node. Packages stay external and resolve as usual. A package linked into `node_modules` from outside it, such as a workspace package, is local code: bongo bundles it too, and the packages it imports resolve from its own folder. `import.meta.url`, `import.meta.dirname`, and `__dirname` keep pointing at each source file. TypeScript partials, `data/` modules, and [data modules](/data-modules/) load the same way. It also loads the files in `data/` as `$data`.
64
+
2.`bongo build` keeps the files of the last build in the output folder, which the config can name, to write over them. The [record of the last build](/cli/#incremental-builds) lists them; without it, bongo lists the folder and deletes each symlink in it. It collects layouts from `layouts/` and partials from `partials/`. It compiles the Handlebars files (`.hbs`) with tempura, and loads the JavaScript and TypeScript partials as modules.
65
65
3. It passes the content files through the registered [loaders](/loaders/), then renders each page through its matching [layout chain](/templates/#layouts). A page that no change reached since the last build keeps its file and skips its loaders. See [Incremental builds](/cli/#incremental-builds). [Output files](/output-files/), such as `sitemap.xml.hbs`, get no layout. [Data modules](/data-modules/), such as `search.json.ts`, run when every page is known, and write JSON.
66
66
4. It scans the rendered HTML for `<bongo:*>` elements, and the content of each page for `<img>` elements with a relative `src`. It registers each asset and replaces it with a placeholder token.
67
67
5. It flushes the asset groups. JavaScript goes through Rolldown, CSS goes through LightningCSS, and images go through `Bun.Image`. Output file names include content hashes.
68
68
6. It replaces the placeholders with external asset URLs or with inline asset contents.
69
-
7. It passes each page and output file to [`$hooks.transform`](/hooks/), and writes the pages to `public/`. `bongo dev` keeps them in memory. So that a large site does not fill the memory, `bongo build` writes each page to `public/` as soon as it renders, then reads it again for steps 6 and 7. Last, it deletes each file of the last build that this build did not write. With `--minify`, it then minifies the pages when the `minify` CLI is available. See [Minify](/cli/#minify).
69
+
7. It passes each page and output file to [`$hooks.transform`](/hooks/), and writes the pages to the output folder. `bongo dev` keeps them in memory. So that a large site does not fill the memory, `bongo build` writes each page to `public/` as soon as it renders, then reads it again for steps 6 and 7. Last, it deletes each file of the last build that this build did not write. With `--minify`, it then minifies the pages when the `minify` CLI is available. See [Minify](/cli/#minify).
0 commit comments