I originally wanted to make it clearer the distinction between "files" and e.g. `` ```tsx foo.tsx `` compared to `` ```sh Terminal `` or `` ```txt Project structure``. I originally started just trying to add a 📝 icon or something. But instead I ended showing file types of all markdown languages. I took the file type icons for the SVG's from https://github.com/vscode-icons/vscode-icons, which has a MIT license. I think the icons make it a even more clear what the language of the code snippet is. I have a follow-up PR for improving code block titles and making examples more consistent in #3163. ## Comparisons <details> <summary><strong>Open — Before | After</strong></summary> ### TS + Shell icons - Hover tooltips and alt text <img width="1504" height="639" alt="image" src="https://github.com/user-attachments/assets/636838a3-f38c-4048-a536-52c1cdd6b6d4" /> ### TS + Shell icons 2 <img width="1511" height="761" alt="image" src="https://github.com/user-attachments/assets/2ad6d25c-3995-433a-ad93-162830ca55a1" /> ### Shell + Dockerfile icons <img width="1500" height="780" alt="image" src="https://github.com/user-attachments/assets/88010749-d0d2-4498-9eb2-9bd971e48365" /> ### Nested blocks + Git icon <img width="1513" height="634" alt="image" src="https://github.com/user-attachments/assets/400c27f8-d0b4-40bd-801d-611e1e8a8e36" /> </details>
65 lines
2.4 KiB
Markdown
65 lines
2.4 KiB
Markdown
---
|
|
description: |
|
|
To start a Fresh project, just run `deno task start`. This will start the
|
|
project with default permission flags, in watch mode.
|
|
---
|
|
|
|
The next step after scaffolding out a new project, is to actually start it. To
|
|
do this you can just `deno task start`. Environment variables will be
|
|
automatically read from `.env`.
|
|
|
|
```sh Terminal
|
|
$ deno task start
|
|
Watcher Process started.
|
|
🍋 Fresh ready
|
|
Local: http://localhost:8000
|
|
```
|
|
|
|
If you want to start manually without Deno task, `deno run` the `main.ts` with
|
|
the appropriate flags. You will need to provide permission flags for:
|
|
|
|
- **`--allow-net`**: This is required to start the HTTP server.
|
|
- **`--allow-read`**: This is required to read (static) files from disk.
|
|
- **`--allow-env`**: This is required to read environment variables that can be
|
|
used to configure your project.
|
|
- **`--allow-run`**: This is required to shell out to `deno` and `esbuild` under
|
|
the hood during development to do type stripping. In production this is done
|
|
using a WebAssembly binary.
|
|
|
|
For development, you also want to run with the [`--watch` flag][--watch], so the
|
|
Fresh server will automatically reload whenever you make a change to your code.
|
|
By default `--watch` only watches over files in your module graph. Some project
|
|
files like static files are not part of the module graph, but you probably want
|
|
to restart/reload whenever you make a change to them too. This can be done by
|
|
passing the extra folder as an argument: `--watch=static/`. You should also add
|
|
`routes/` to the watch list, so that the server restarts automatically whenever
|
|
you add a new route.
|
|
|
|
If you want to change the port or host, modify the config bag of the `start()`
|
|
call in `main.ts` to include an explicit port number:
|
|
|
|
```ts main.ts
|
|
await start(manifest, { server: { port: 3000 } });
|
|
```
|
|
|
|
You can also change the port by setting the `PORT` environment variable:
|
|
|
|
```sh Terminal
|
|
$ PORT=3000 deno task start
|
|
```
|
|
|
|
Combining all of this we get the following `deno run` command:
|
|
|
|
```sh Terminal
|
|
$ deno run --allow-net --allow-read --allow-env --allow-run --watch=static/,routes/ main.ts
|
|
Watcher Process started.
|
|
🍋 Fresh ready
|
|
Local: http://localhost:3000
|
|
```
|
|
|
|
If you now visit http://localhost:3000, you can see the running project. Try
|
|
change some of the text in `routes/index.tsx` and see how the page updates
|
|
automatically when you save the file.
|
|
|
|
[--watch]: https://docs.deno.com/runtime/getting_started/command_line_interface/#watch-mode
|