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 }}
This repository was archived by the owner on Sep 12, 2019. It is now read-only.
Now you're both ready to start testing netlify dev and to contribute to the project.
31
31
32
-
## Functionality Notes
32
+
### Netlify Dev usage
33
+
34
+
```bash
35
+
USAGE
36
+
$ netlify dev
37
+
38
+
OPTIONS
39
+
-c, --cmd=cmd command to run
40
+
-d, --devport=devport port of the dev server started by command
41
+
-d, --dir=dir dir with static files
42
+
-f, --functions=functions Specify a functions folder to serve
43
+
-o, --offline disables any features that require network access
44
+
-p, --port=port port of netlify dev
45
+
46
+
DESCRIPTION
47
+
The dev command will run a local dev server with Netlify's proxy and redirect rules
48
+
49
+
EXAMPLES
50
+
$ netlify dev
51
+
$ netlify dev -c "yarn start"
52
+
$ netlify dev -c hugo
53
+
54
+
COMMANDS
55
+
dev:exec Exec command
56
+
```
57
+
58
+
### Redirects
59
+
60
+
Netlify Dev has the ability emulate the [redirect capability](https://www.netlify.com/docs/redirects/) Netlify provide on the [ADN](https://netlify.com/features/adn) in your local environment. The same redirect rules which you configure to run on the edge, will also work in your local builds.
61
+
62
+
Netlify dev supports redirect rules defined in either `_redirects` or `netlify.toml` files.
63
+
64
+
The order of precedence for applying redirect rules is:
65
+
66
+
1. `_redirects` file (in the project's publish folder)
67
+
1. `netlify.toml` file (in the project's publish folder)
68
+
1. `netlify.toml` file (in the project's root folder)
69
+
70
+
See the [Redirects Documentation](https://www.netlify.com/docs/redirects/) for more information on Netlify's redirect and proxying capabilities.
71
+
72
+
73
+
#### Running the project and accessing redirects
74
+
```bash
75
+
# Build, serve and hot-reload changes
76
+
$ netlify dev
77
+
```
78
+
79
+
80
+
### Project detection
81
+
82
+
Netlify Dev will attempt to detect the SSG or build command that you are using, and run these on your behalf, while adding other development utilities.
83
+
84
+
The number of project types which Netlify Dev can detect is growing, but if yours is not yet supported automatically, you can instruct Netlify Dev to run the project on your behalf by declaring it in a `[dev]` block of your `netlify.toml` file.
85
+
86
+
```toml
33
87
34
-
-`netlify dev` now supports both `_redirects` and `netlify.toml` for redirects and has the same logic around loading order as our system (\_redirects, toml in public folder, toml in base)
35
-
-`netlify dev` can be configured for projects we don’t detect out of the box with a `[dev]` block in the toml file
88
+
#sample dev block in the toml
89
+
[dev]
90
+
#TODO: what does this look like?
36
91
37
-
## `netlify functions:create`
92
+
```
93
+
94
+
95
+
### Netlify Functions
96
+
97
+
Netlify can also create serverless functions for you locally as part of Netlify Functions. The serverless functions can then be run by Netlify Dev in the same way that wold be when deployed to the cloud.
38
98
39
-
Create a new function from a given template.
99
+
A number of function templates are available to get you started, and you can add your own utility functions to suit your own project development needs.
You can just call `netlify functions:create` and the prompts will guide you all the way, however you can also supply a first argument to name the function. By default it creates a single file, however you can also use a `--dir` flag to create a function as a directory.
128
+
#### Executing Netlify Functions
129
+
130
+
After creating serverless functions, Netlify Dev can serve thes to you as part of your local build. This emulates the behaviour of Netlify Functions when deployed to Netlify.
131
+
132
+
```bash
133
+
# Build, serve and hot-reload changes
134
+
$ netlify dev
135
+
```
136
+
137
+
Each serverless function will be exposed on a URL corresponding to its path and file name.
By passing a URL to a folder in a github repo to the `--url` flag, you can clone new templates. Dependencies are installed inside its own folder. Example: `netlify functions:create hello-world --url https://github.com/netlify-labs/all-the-functions/tree/master/functions/9-using-middleware`
0 commit comments