docs: add "Changing the source directory" example (#1286)
Co-authored-by: Asher Gomez <ashersaupingomez@gmail.com>
This commit is contained in:
co-authored by
Asher Gomez
parent
f833c7262d
commit
673ed2d90f
@@ -0,0 +1,76 @@
|
|||||||
|
---
|
||||||
|
description: |
|
||||||
|
Change the source directory to effectively manage your project.
|
||||||
|
---
|
||||||
|
|
||||||
|
When you initialize a project with `deno run -A -r https://fresh.deno.dev`,
|
||||||
|
you'll end up with a project like the following:
|
||||||
|
|
||||||
|
```
|
||||||
|
.
|
||||||
|
├── README.md
|
||||||
|
├── components
|
||||||
|
│ └── Button.tsx
|
||||||
|
├── deno.json
|
||||||
|
├── dev.ts
|
||||||
|
├── fresh.gen.ts
|
||||||
|
├── islands
|
||||||
|
│ └── Counter.tsx
|
||||||
|
├── main.ts
|
||||||
|
├── routes
|
||||||
|
│ ├── [name].tsx
|
||||||
|
│ ├── api
|
||||||
|
│ │ └── joke.ts
|
||||||
|
│ └── index.tsx
|
||||||
|
└── static
|
||||||
|
├── favicon.ico
|
||||||
|
└── logo.svg
|
||||||
|
```
|
||||||
|
|
||||||
|
## Using a `src` directory
|
||||||
|
|
||||||
|
If you'd like your code to live in an `src` directory (or any other directory of
|
||||||
|
your choosing), then you'll need to do the following things:
|
||||||
|
|
||||||
|
1. Move all your files, except `deno.json` and `README.md`, to the `src`
|
||||||
|
directory.
|
||||||
|
2. Modify the `start` task in `deno.json` to point to the new directory.
|
||||||
|
|
||||||
|
Here's what the diff of `deno.json` looks like:
|
||||||
|
|
||||||
|
```diff
|
||||||
|
{
|
||||||
|
"lock": false,
|
||||||
|
"tasks": {
|
||||||
|
- "start": "deno run -A --watch=static/,routes/ dev.ts"
|
||||||
|
+ "start": "deno run -A --watch=src/static/,src/routes/ src/dev.ts"
|
||||||
|
},
|
||||||
|
"imports": {
|
||||||
|
"$fresh/": "file:///Users/reed/code/fresh/",
|
||||||
|
```
|
||||||
|
|
||||||
|
The resulting file structure looks like this:
|
||||||
|
|
||||||
|
```
|
||||||
|
.
|
||||||
|
├── README.md
|
||||||
|
├── deno.json
|
||||||
|
└── src
|
||||||
|
├── components
|
||||||
|
│ └── Button.tsx
|
||||||
|
├── dev.ts
|
||||||
|
├── fresh.gen.ts
|
||||||
|
├── islands
|
||||||
|
│ └── Counter.tsx
|
||||||
|
├── main.ts
|
||||||
|
├── routes
|
||||||
|
│ ├── [name].tsx
|
||||||
|
│ ├── api
|
||||||
|
│ │ └── joke.ts
|
||||||
|
│ └── index.tsx
|
||||||
|
└── static
|
||||||
|
├── favicon.ico
|
||||||
|
└── logo.svg
|
||||||
|
```
|
||||||
|
|
||||||
|
Success! Your code now lives elsewhere.
|
||||||
@@ -11,3 +11,4 @@ like to see here, please open
|
|||||||
- [Modifying the `<head>`](./examples/modifying-the-head)
|
- [Modifying the `<head>`](./examples/modifying-the-head)
|
||||||
- [Setting the language](./examples/setting-the-language)
|
- [Setting the language](./examples/setting-the-language)
|
||||||
- [Writing tests](./examples/writing-tests)
|
- [Writing tests](./examples/writing-tests)
|
||||||
|
- [Changing the source directory](./changing-the-src-dir.md)
|
||||||
|
|||||||
+2
-1
@@ -43,7 +43,8 @@
|
|||||||
"pages": [
|
"pages": [
|
||||||
["modifying-the-head", "Modifying the <head>"],
|
["modifying-the-head", "Modifying the <head>"],
|
||||||
["setting-the-language", "Setting the language"],
|
["setting-the-language", "Setting the language"],
|
||||||
["writing-tests", "Writing tests"]
|
["writing-tests", "Writing tests"],
|
||||||
|
["changing-the-src-dir", "Changing the source directory"]
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user