Skip to content
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

feat: create official Netlify Remix template #83

Merged
merged 43 commits into from
Feb 24, 2023
Merged
Show file tree
Hide file tree
Changes from 35 commits
Commits
Show all changes
43 commits
Select commit Hold shift + click to select a range
9acd178
chore: updated eslint configuration for template
nickytonline Feb 10, 2023
4c12998
chore: updated gitignore
nickytonline Feb 10, 2023
daaf46d
chore: updated template
nickytonline Feb 10, 2023
dc06b86
Merge remote-tracking branch 'origin/main' into nickytonline/update-t…
nickytonline Feb 10, 2023
a29a2b2
chore: fixed node package change for new template references
nickytonline Feb 10, 2023
0ff5692
chore: first batch of updates to template
nickytonline Feb 14, 2023
b0109a0
chore: added an example of cache headers
nickytonline Feb 15, 2023
48e08e6
chore: some markup cleanup
nickytonline Feb 15, 2023
d560631
chore: removed package lock
nickytonline Feb 15, 2023
7bda544
chore: put back globals.d.ts
nickytonline Feb 15, 2023
73c22a4
Revert "chore: first batch of updates to template"
nickytonline Feb 16, 2023
2ffae3a
chore: removed headers from edge version of netlify.toml
nickytonline Feb 16, 2023
69e8617
chore: put back node eslint config
nickytonline Feb 16, 2023
1a8d04d
chore: updated tsconfig.json
nickytonline Feb 16, 2023
4928004
chore: folders can now be excluded from template generation
nickytonline Feb 18, 2023
480051b
chore: added force to removing the excluded folders
nickytonline Feb 18, 2023
2c603f3
chore: netlify configurations and READMEs get set by remix.init now
nickytonline Feb 18, 2023
330b1a5
chore: added README for the project, not the templates
nickytonline Feb 18, 2023
52fd58b
chore: added a CoC and contributing guidelines
nickytonline Feb 18, 2023
db09d8e
chore: shortened cache control time example headers for Remix running…
nickytonline Feb 18, 2023
3b4f673
Merge branch 'main' into nickytonline/update-template
nickytonline Feb 18, 2023
e0ca52a
chore: removed references to Netlify Graph
nickytonline Feb 20, 2023
5b5eda5
chore: removed unnecessary disabling of lint rule
nickytonline Feb 20, 2023
547422f
Update remix.init/index.js
nickytonline Feb 20, 2023
4f2270b
Update README.md
nickytonline Feb 20, 2023
f1526f3
Update remix.init/README.md
nickytonline Feb 20, 2023
5b133cf
Update README.md
nickytonline Feb 20, 2023
09af36a
Update remix.init/README-edge.md
nickytonline Feb 20, 2023
e9576e9
chore: README updates
nickytonline Feb 20, 2023
fd3139b
chore: edge template now uses renderReadableStream
nickytonline Feb 21, 2023
d86cc3b
chore: small cleanup
nickytonline Feb 21, 2023
6603201
Update remix.init/README-edge.md
nickytonline Feb 22, 2023
ba24c63
chore: remix.init ignores toml files so changed filename
nickytonline Feb 22, 2023
41a1243
chore: fixed file copy issues when project language is JS
nickytonline Feb 22, 2023
cbe3f15
chore: excluded the .gitfolder from template generation
nickytonline Feb 22, 2023
2de5663
chore: removed debugger statement
nickytonline Feb 22, 2023
0d8a01c
chore: fixed issue with isbot require
nickytonline Feb 22, 2023
e7122a1
chore: added a step to mention running npm install in case remix.init…
nickytonline Feb 22, 2023
3c57b0c
chore: added /_assets/* to exclude_patterns and documented excluding …
nickytonline Feb 23, 2023
973d282
chore: added missing await
nickytonline Feb 24, 2023
faa0b8b
chore: added final step to install additional packages for edge setup
nickytonline Feb 24, 2023
887128c
Update remix.init/README-edge.md
nickytonline Feb 24, 2023
be32ac6
chore: added an explainer on how to use the template
nickytonline Feb 24, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 0 additions & 3 deletions .eslintrc

This file was deleted.

4 changes: 4 additions & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
/** @type {import('eslint').Linter.Config} */
module.exports = {
extends: ["@remix-run/eslint-config", "@remix-run/eslint-config/node"],
};
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,7 @@ node_modules

/.cache
/public/build
/.netlify
.env

# Local Netlify folder
.netlify
12 changes: 0 additions & 12 deletions .vscode/settings.json

This file was deleted.

60 changes: 60 additions & 0 deletions CODE_OF_CONDUCT.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
# Contributor Covenant Code of Conduct

## Our Pledge

In the interest of fostering an open and welcoming environment, we as contributors and maintainers pledge to making
participation in our project and our community a harassment-free experience for everyone, regardless of age, body size,
disability, ethnicity, gender identity and expression, level of experience, nationality, personal appearance, race,
religion, or sexual identity and orientation.

## Our Standards

Examples of behavior that contributes to creating a positive environment include:

- Using welcoming and inclusive language
- Being respectful of differing viewpoints and experiences
- Gracefully accepting constructive criticism
- Focusing on what is best for the community
- Showing empathy towards other community members

Examples of unacceptable behavior by participants include:

- The use of sexualized language or imagery and unwelcome sexual attention or advances
- Trolling, insulting/derogatory comments, and personal or political attacks
- Public or private harassment
- Publishing others' private information, such as a physical or electronic address, without explicit permission
- Other conduct which could reasonably be considered inappropriate in a professional setting

## Our Responsibilities

Project maintainers are responsible for clarifying the standards of acceptable behavior and are expected to take
appropriate and fair corrective action in response to any instances of unacceptable behavior.

Project maintainers have the right and responsibility to remove, edit, or reject comments, commits, code, wiki edits,
issues, and other contributions that are not aligned to this Code of Conduct, or to ban temporarily or permanently any
contributor for other behaviors that they deem inappropriate, threatening, offensive, or harmful.

## Scope

This Code of Conduct applies both within project spaces and in public spaces when an individual is representing the
project or its community. Examples of representing a project or community include using an official project e-mail
address, posting via an official social media account, or acting as an appointed representative at an online or offline
event. Representation of a project may be further defined and clarified by project maintainers.

## Enforcement

Instances of abusive, harassing, or otherwise unacceptable behavior may be reported by contacting the project team. The
project team will review and investigate all complaints, and will respond in a way that it deems appropriate to the
circumstances. The project team is obligated to maintain confidentiality with regard to the reporter of an incident.
Further details of specific enforcement policies may be posted separately.

Project maintainers who do not follow or enforce the Code of Conduct in good faith may face temporary or permanent
repercussions as determined by other members of the project's leadership.

## Attribution

This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4, available at
[http://contributor-covenant.org/version/1/4][version]

[homepage]: http://contributor-covenant.org
[version]: http://contributor-covenant.org/version/1/4/
50 changes: 50 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
# Contributions

🎉 Thanks for considering contributing to this project! 🎉

When contributing to this repository, please first discuss the change you wish to make via an
[issue](https://github.com/netlify/remix-template/issues/new/choose). Please use the issue templates. They are there to
help you and to help the maintainers gather information.

Before working on an issue, ask to be assigned to it. This makes it clear to other potential contributors that someone
is working on the issue.

When creating a PR, please use the template. The information in the template helps maintainers review your pull
request.```

This project was made with ❤️. The simplest way to give back is by starring and sharing it online.

Everyone is welcome regardless of personal background. We enforce a [Code of conduct](CODE_OF_CONDUCT.md) in order to
promote a positive and inclusive environment.

## Development process

First fork and clone the repository. If you're not sure how to do this, please watch
[these videos](https://egghead.io/courses/how-to-contribute-to-an-open-source-project-on-github).

Run:

```bash
npm install
```

Make sure everything is correctly setup with:

```bash
npm test
```

## How to write commit messages

We use [Conventional Commit messages](https://www.conventionalcommits.org/) to automate version management.

Most common commit message prefixes are:

- `fix:` which represents bug fixes, and generate a patch release.
- `feat:` which represents a new feature, and generate a minor release.
- `feat!:`, `fix!:` or `refactor!:` and generate a major release.

## Releasing

1. Merge the release PR
2. Run `npm publish`
66 changes: 12 additions & 54 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,65 +1,23 @@
# Welcome to Remix!
# Netlify Remix Template

This template uses the Netlify Edge Functions beta to deploy your Remix site.
Welcome to the Netlify Remix Template project.
nickytonline marked this conversation as resolved.
Show resolved Hide resolved

<a href="https://app.netlify.com/start/deploy?repository=https://github.com/netlify/remix-edge-template"><img src="https://www.netlify.com/img/deploy/button.svg" alt="Deploy to Netlify"></a>

- [Remix Docs](https://remix.run/docs)

## Netlify Setup

1. Install the [Netlify CLI](https://www.netlify.com/products/dev/):

```sh
npm i -g netlify-cli
```

If you have previously installed the Netlify CLI, you should update it to the latest version:

```sh
npm i -g netlify-cli@latest
```

2. Sign up and log in to Netlify:

```sh
netlify login
```

3. Create a new site:

```sh
netlify init
```
This project includes:
- Netlify Functions template for Remix sites
- Netlify Edge Functions template for Remix sites

## Development

The Remix dev server starts your app in development mode, rebuilding assets on file changes. To start the Remix dev server:
There is no need to run `npm install` as this is a template. The Remix CLI will install the dependencies for you. Make changes to files as you see fit. If there are transformations for files for either the Netlify Functions or Netlify Edge Functions template, make the appropriate changes to the `remix.init/index.js` file.

```sh
npm run dev
```
If you're new to Remix stacks and the remix.init concept, see the official [Remix Stacks](https://remix.run/stacks) documentation.

Open up [http://localhost:3000](http://localhost:3000), and you should be ready to go!
### Testing your changes

The Netlify CLI builds a production version of your Remix App Server and splits it into Netlify Functions that run locally. This includes any custom Netlify functions you've developed. The Netlify CLI runs all of this in its development mode.
Run

```sh
netlify dev
```bash
npx create-remix --template ./
```

Open up [http://localhost:3000](http://localhost:3000), and you should be ready to go!

Note: When running the Netlify CLI, file changes will rebuild assets, but you will not see the changes to the page you are on unless you do a browser refresh of the page. Due to how the Netlify CLI builds the Remix App Server, it does not support hot module reloading.

## Deployment

There are two ways to deploy your app to Netlify, you can either link your app to your git repo and have it auto deploy changes to Netlify, or you can deploy your app manually. If you've followed the setup instructions already, all you need to do is run this:

```sh
# preview deployment
netlify deploy --build

# production deployment
netlify deploy --build --prod
```
to test your changes to the template. Follow the steps the Remix CLI prompts you with to create a new project. Ensure to test for both the Netlify Functions template and the Netlify Edge Functions template.
20 changes: 19 additions & 1 deletion app/entry.client.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,22 @@
import { RemixBrowser } from "@remix-run/react";
import { startTransition, StrictMode } from "react";
import { hydrateRoot } from "react-dom/client";

hydrateRoot(document, <RemixBrowser />);
function hydrate() {
startTransition(() => {
hydrateRoot(
document,
<StrictMode>
<RemixBrowser />
</StrictMode>
);
});
}

if (window.requestIdleCallback) {
window.requestIdleCallback(hydrate);
} else {
// Safari doesn't support requestIdleCallback
// https://caniuse.com/requestidlecallback
window.setTimeout(hydrate, 1);
}
24 changes: 7 additions & 17 deletions app/entry.server.tsx
Original file line number Diff line number Diff line change
@@ -1,31 +1,21 @@
import type { EntryContext } from "@remix-run/server-runtime";
import type { EntryContext } from "@remix-run/node";
import { RemixServer } from "@remix-run/react";
import { renderToReadableStream } from "react-dom/server";
import isbot from "isbot";
import { renderToString } from "react-dom/server";

export default async function handleRequest(
export default function handleRequest(
request: Request,
responseStatusCode: number,
responseHeaders: Headers,
remixContext: EntryContext
) {
let body = await renderToReadableStream(
<RemixServer context={remixContext} url={request.url} />,
{
onError() {
responseStatusCode = 500;
},
}
const markup = renderToString(
<RemixServer context={remixContext} url={request.url} />
);

if (isbot(request.headers.get("user-agent"))) {
await body.allReady;
}

responseHeaders.set("Content-Type", "text/html");

return new Response(body, {
status: responseStatusCode,
return new Response("<!DOCTYPE html>" + markup, {
headers: responseHeaders,
status: responseStatusCode,
});
}
2 changes: 1 addition & 1 deletion app/root.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import type { MetaFunction } from "@remix-run/server-runtime";
import type { MetaFunction } from "@remix-run/node";
import {
Links,
LiveReload,
Expand Down
31 changes: 26 additions & 5 deletions app/routes/index.tsx
Original file line number Diff line number Diff line change
@@ -1,13 +1,30 @@
export function headers({
loaderHeaders,
parentHeaders,
}: {
loaderHeaders: Headers;
parentHeaders: Headers;
}) {
console.log(
"This is an example of how to set caching headers for a route, feel free to change the value of 60 seconds or remove the header"
);
return {
// This is an example of how to set caching headers for a route
// For more info on headers in Remix, see: https://remix.run/docs/en/v1/route/headers
"Cache-Control": "public, max-age=60, s-maxage=60",
};
}

export default function Index() {
return (
<div style={{ fontFamily: "system-ui, sans-serif", lineHeight: "1.4" }}>
<main style={{ fontFamily: "system-ui, sans-serif", lineHeight: "1.4" }}>
<h1>Welcome to Remix</h1>
<ul>
<li>
<a
target="_blank"
href="https://remix.run/tutorials/blog"
rel="noreferrer"
rel="noreferrer noopener"
>
15m Quickstart Blog Tutorial
</a>
Expand All @@ -16,17 +33,21 @@ export default function Index() {
<a
target="_blank"
href="https://remix.run/tutorials/jokes"
rel="noreferrer"
rel="noreferrer noopener"
>
Deep Dive Jokes App Tutorial
</a>
</li>
<li>
<a target="_blank" href="https://remix.run/docs" rel="noreferrer">
<a
target="_blank"
href="https://remix.run/docs"
rel="noreferrer noopener"
>
Remix Docs
</a>
</li>
</ul>
</div>
</main>
);
}
13 changes: 0 additions & 13 deletions netlify.toml

This file was deleted.

Loading