-
Notifications
You must be signed in to change notification settings - Fork 1.4k
feat: add Netlify starter #471
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
67c4780
feat: add Netlify starter
ascorbic d548fa9
fix: include manifest
ascorbic 3b23f12
chore: add Netlify README
ascorbic 32d67e9
refactor: changes to reflect new options
ascorbic 0fc4986
fix: make manifest work
ascorbic 236ddfb
docs: apply suggestions from code review
ascorbic 5ea158f
Merge branch 'main' into mk/netlify-starter
adamdbradley de3754f
Merge branch 'main' into mk/netlify-starter
adamdbradley d090182
Merge branch 'main' into mk/netlify-starter
adamdbradley 1168d05
chore: format
ascorbic eee9294
Merge branch 'main' into mk/netlify-starter
adamdbradley File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
16 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
## Netlify | ||
|
||
This starter site is configured to deploy to [Netlify Edge Functions](https://www.netlify.com/products/edge/), which means it will be rendered at an edge location near to your users. | ||
|
||
### Local development | ||
|
||
The [Netlify CLI](https://docs.netlify.com/cli/get-started/) can be used to preview a production build locally. To do so: First build your site, then to start a local server, run: | ||
|
||
1. Build your site with `netlify build`. | ||
2. Start a local server with `npm run serve`. | ||
In this project, `npm run serve` uses the `netlify dev` command to spin up a server that can handle Netlify's Edge Functions locally. | ||
3. Visit [http://localhost:8888/](http://localhost:8888/) to check out your site. | ||
|
||
### Deployments | ||
|
||
You can [deploy your site to Netlify](https://docs.netlify.com/site-deploys/create-deploys/) either via a Git provider integration or through the Netlify CLI. This starter site includes a `netlify.toml` file to configure your build for deployment. | ||
|
||
#### Deploying via Git | ||
|
||
Once your site has been pushed to your Git provider, you can either link it [in the Netlify UI](https://app.netlify.com/start) or use the CLI. To link your site to a Git provider from the Netlify CLI, run the command: | ||
|
||
```shell | ||
netlify link | ||
``` | ||
|
||
This sets up [continuous deployment](https://docs.netlify.com/site-deploys/create-deploys/#deploy-with-git) for your site's repo. Whenever you push new commits to your repo, Netlify starts the build process.. | ||
|
||
#### Deploying manually via the CLI | ||
|
||
If you wish to deploy from the CLI rather than using Git, you can use the command: | ||
|
||
```shell | ||
netlify deploy --build | ||
``` | ||
|
||
You must use the `--build` flag whenever you deploy. This ensures that the Edge Functions that this starter site relies on are generated and available when you deploy your site. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
[build] | ||
publish = "dist" | ||
command = "npm run build" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
{ | ||
"description": "Netlify Edge Functions.", | ||
"scripts": { | ||
"serve": "netlify dev", | ||
"build.ssr": "vite build --ssr src/entry.netlify.ts" | ||
}, | ||
"devDependencies": { | ||
"@netlify/vite-plugin-netlify-edge": "^1.1.0" | ||
}, | ||
"qwik": { | ||
"priority": -1 | ||
} | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
/build/* | ||
Cache-Control: public, max-age=31536000, s-maxage=31536000, immutable |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
import { render } from './entry.ssr'; | ||
|
||
const handler = async (request: Request) => { | ||
try { | ||
// Handle static files | ||
if (/\.\w+$/.test(request.url)) { | ||
return; | ||
} | ||
|
||
const ssrResult = await render({ | ||
url: request.url, | ||
base: '/build/', | ||
}); | ||
|
||
const response = new Response(ssrResult.html, { | ||
headers: { | ||
'Content-Type': 'text/html; charset=utf-8', | ||
}, | ||
}); | ||
return response; | ||
} catch (e) { | ||
// 500 Error | ||
return new Response(String(e), { status: 500 }); | ||
} | ||
}; | ||
|
||
export default handler; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
{ | ||
"compilerOptions": { | ||
"target": "ES2017", | ||
"module": "ES2020", | ||
"lib": ["es2020", "DOM"], | ||
"jsx": "react-jsx", | ||
"jsxImportSource": "@builder.io/qwik", | ||
"strict": true, | ||
"resolveJsonModule": true, | ||
"moduleResolution": "node", | ||
"esModuleInterop": true, | ||
"skipLibCheck": true, | ||
"incremental": true, | ||
"types": ["vite/client"] | ||
}, | ||
"include": ["src"] | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
import { defineConfig } from 'vite'; | ||
import netlifyEdge from '@netlify/vite-plugin-netlify-edge'; | ||
import { qwikVite } from '@builder.io/qwik/optimizer'; | ||
|
||
export default defineConfig(() => { | ||
return { | ||
plugins: [ | ||
qwikVite({ | ||
ssr: { outDir: '.netlify/edge-functions/entry.netlify' }, | ||
}), | ||
netlifyEdge({ | ||
functionName: 'entry.netlify', | ||
}), | ||
], | ||
}; | ||
}); |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.