Merge branch 'tzm/deploySetup' into tzm/4/addNetlifyForm
This commit is contained in:
commit
335462cfba
3
.gitignore
vendored
3
.gitignore
vendored
@ -88,3 +88,6 @@ sw.*
|
|||||||
|
|
||||||
# Vim swap files
|
# Vim swap files
|
||||||
*.swp
|
*.swp
|
||||||
|
|
||||||
|
# Local Netlify folder
|
||||||
|
.netlify
|
||||||
|
38
README.md
38
README.md
@ -16,8 +16,44 @@ $ npm run start
|
|||||||
# generate static project
|
# generate static project
|
||||||
$ npm run generate
|
$ npm run generate
|
||||||
```
|
```
|
||||||
## Redirects
|
|
||||||
|
|
||||||
|
## Deploy to Netlify
|
||||||
|
---
|
||||||
|
Want to deploy immediately? Click this button
|
||||||
|
|
||||||
|
[](https://app.netlify.com/start/deploy?repository=https://github.com/netlify-templates/nuxt-toolbox)
|
||||||
|
|
||||||
|
To deploy using the Netlify cli:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
npm install netlify-cli -g # to install the Netlify CLI tool globally
|
||||||
|
netlify init # initialize a new Netlify project & deploy
|
||||||
|
```
|
||||||
|
|
||||||
|
It will use the information from the included Netlify configuration file, [`netlify.toml`](./netlify.toml), to set up the build command as `npm run generate` to create a static project and locate the build project in the `dist` directory.
|
||||||
|
|
||||||
|
The `init` process will also set up continuous deployemnt for your project so that a new build will be triggered & deployed when you push code to the repo (you can change this from your project dashboard: Site Settings/Build & deploy/Continuous Deployment).
|
||||||
|
|
||||||
|
You can also use `netlify deploy (--prod)` to manually deploy and `netlify open` to open your project dashboard.
|
||||||
|
|
||||||
|
> 💡 we only have so many keystrokes to give, use `ntl` shorthand for `netlify` or make [an alias of your own](https://www.netlify.com/blog/2020/04/12/speed-up-productivity-with-terminal-aliases/) to save hours...of accumulated miliseconds
|
||||||
|
|
||||||
|
### Running Locally
|
||||||
|
|
||||||
|
You can use `netlify dev` from the command line to access project information like environment variables as well as
|
||||||
|
- test functions
|
||||||
|
- test redirects
|
||||||
|
- share a live session via url with `netlify dev --live`
|
||||||
|
- [and more](https://cli.netlify.com/netlify-dev/) :)
|
||||||
|
|
||||||
|
### Deployment Resources
|
||||||
|
- [CLI docs](https://docs.netlify.com/cli/get-started/)
|
||||||
|
- [File-based Netlify Configuration](https://docs.netlify.com/configure-builds/file-based-configuration/)
|
||||||
|
- [Netlify Dev Overview](https://www.youtube.com/watch?v=RL_gtVZ_79Q&t=812s)
|
||||||
|
- [Netlify Edge, CDN deployment](https://www.netlify.com/products/edge/)
|
||||||
|
|
||||||
|
## Redirects
|
||||||
|
---
|
||||||
In the [`netlify.toml`](./netlify.toml) configuration file there is an example of how to implement redirects. Redirects can be used to do many things from redirecting Single Page Apps more predictably, redirecting based on country/language to leveraging On-Demand Builders for [Distributed Persistant Rendering](https://www.netlify.com/blog/2021/04/14/distributed-persistent-rendering-a-new-jamstack-approach-for-faster-builds/).
|
In the [`netlify.toml`](./netlify.toml) configuration file there is an example of how to implement redirects. Redirects can be used to do many things from redirecting Single Page Apps more predictably, redirecting based on country/language to leveraging On-Demand Builders for [Distributed Persistant Rendering](https://www.netlify.com/blog/2021/04/14/distributed-persistent-rendering-a-new-jamstack-approach-for-faster-builds/).
|
||||||
|
|
||||||
In the example we'll be using redirects to have a shorter endpoint to Netlify functions. By default, you call a Netlify function when requesting a path like `https://yoursite.netlify.com/.netlify/functions/functionName`. Instead, we'll redirect all calls from a path including `/api` to call on the Netlify functions. So the path will be `https://yoursite.netlify.com/api/functionName`, a lot easier to remember too.
|
In the example we'll be using redirects to have a shorter endpoint to Netlify functions. By default, you call a Netlify function when requesting a path like `https://yoursite.netlify.com/.netlify/functions/functionName`. Instead, we'll redirect all calls from a path including `/api` to call on the Netlify functions. So the path will be `https://yoursite.netlify.com/api/functionName`, a lot easier to remember too.
|
||||||
|
23
netlify.toml
23
netlify.toml
@ -1,12 +1,17 @@
|
|||||||
# This is the configuration file for Netlify
|
## This is the configuration file for Netlify
|
||||||
# https://docs.netlify.com/configure-builds/file-based-configuration/
|
## https://docs.netlify.com/configure-builds/file-based-configuration/
|
||||||
|
|
||||||
# Learn more about redirects here
|
[build]
|
||||||
# https://docs.netlify.com/routing/redirects/#syntax-for-the-netlify-configuration-file
|
command = "npm run generate" # how to build your project
|
||||||
# https://docs.netlify.com/routing/redirects/redirect-options/
|
functions = "netlify/functions" # where Netlify Functions live
|
||||||
|
publish = "dist" # where the built project lives
|
||||||
|
|
||||||
|
## Learn more about redirects here
|
||||||
|
## https://docs.netlify.com/routing/redirects/#syntax-for-the-netlify-configuration-file
|
||||||
|
## https://docs.netlify.com/routing/redirects/redirect-options/
|
||||||
|
|
||||||
[[redirects]]
|
[[redirects]]
|
||||||
from = "/api/*" # simplify all calls to serverless functions
|
from = "/api/*" # simplify all calls to serverless functions
|
||||||
to = "/.netlify/functions/:splat" # all function calls will go to this path
|
to = "/.netlify/functions/:splat" # all function calls will go to this path
|
||||||
status = 200 # ok code
|
status = 200 # ok code
|
||||||
force = true # ensure to always redirect
|
force = true # ensure to always redirect
|
||||||
|
Loading…
x
Reference in New Issue
Block a user