Skip to content

Commit 7a47dbf

Browse files
committed
Merge branch 'main' into chore/fix-husky
2 parents 4f3839e + 4da630b commit 7a47dbf

File tree

22 files changed

+18982
-10735
lines changed

22 files changed

+18982
-10735
lines changed

.github/workflows/cypress-demo-nx.yml

Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
name: Run e2e
2+
on:
3+
pull_request:
4+
types: [opened, labeled, unlabeled, synchronize]
5+
push:
6+
branches:
7+
- main
8+
paths:
9+
- 'demos/nx-next-monorepo-demo/**/*.{js,jsx,ts,tsx}'
10+
- 'cypress/integration/nx/**/*.{ts,js}'
11+
- 'src/**/*.{ts,js}'
12+
jobs:
13+
cypress:
14+
runs-on: ubuntu-latest
15+
strategy:
16+
fail-fast: false
17+
matrix:
18+
containers: [1, 2, 3, 4, 5, 6]
19+
steps:
20+
- name: Checkout
21+
uses: actions/checkout@v2
22+
23+
- name: Generate Github token
24+
uses: navikt/github-app-token-generator@v1
25+
id: get-token
26+
with:
27+
private-key: ${{ secrets.TOKENS_PRIVATE_KEY }}
28+
app-id: ${{ secrets.TOKENS_APP_ID }}
29+
30+
- name: Checkout @netlify/wait-for-deploy-action
31+
uses: actions/checkout@v2
32+
with:
33+
repository: netlify/wait-for-deploy-action
34+
token: ${{ steps.get-token.outputs.token }}
35+
path: ./.github/actions/wait-for-netlify-deploy
36+
37+
- name: Wait for Netlify Deploy
38+
id: deploy
39+
uses: ./.github/actions/wait-for-netlify-deploy
40+
with:
41+
site-name: netlify-plugin-nextjs-nx-monorepo-demo
42+
timeout: 300
43+
44+
- name: Deploy successful
45+
if: ${{ steps.deploy.outputs.origin-url }}
46+
run: echo ${{ steps.deploy.outputs.origin-url }}
47+
48+
- name: Node
49+
uses: actions/setup-node@v2
50+
with:
51+
node-version: '16'
52+
53+
- run: npm install
54+
55+
- name: Cypress run
56+
if: ${{ steps.deploy.outputs.origin-url }}
57+
id: cypress
58+
uses: cypress-io/github-action@v2
59+
with:
60+
browser: chrome
61+
headless: true
62+
record: true
63+
parallel: true
64+
config-file: cypress/config/nx-demo.json
65+
env:
66+
DEBUG: '@cypress/github-action'
67+
CYPRESS_baseUrl: ${{ steps.deploy.outputs.origin-url }}
68+
CYPRESS_NETLIFY_CONTEXT: ${{ steps.deploy.outputs.context }}
69+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
70+
CYPRESS_RECORD_KEY: ${{ secrets.NX_CYPRESS_RECORD_KEY }}
Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
name: Run e2e
2+
on:
3+
pull_request:
4+
types: [opened, labeled, unlabeled, synchronize]
5+
push:
6+
branches:
7+
- main
8+
paths:
9+
- 'demos/static-root/**/*.{js,jsx,ts,tsx}'
10+
- 'cypress/integration/static/**/*.{ts,js}'
11+
- 'src/**/*.{ts,js}'
12+
jobs:
13+
cypress:
14+
runs-on: ubuntu-latest
15+
strategy:
16+
fail-fast: false
17+
matrix:
18+
containers: [1, 2, 3, 4, 5, 6]
19+
steps:
20+
- name: Checkout
21+
uses: actions/checkout@v2
22+
23+
- name: Generate Github token
24+
uses: navikt/github-app-token-generator@v1
25+
id: get-token
26+
with:
27+
private-key: ${{ secrets.TOKENS_PRIVATE_KEY }}
28+
app-id: ${{ secrets.TOKENS_APP_ID }}
29+
30+
- name: Checkout @netlify/wait-for-deploy-action
31+
uses: actions/checkout@v2
32+
with:
33+
repository: netlify/wait-for-deploy-action
34+
token: ${{ steps.get-token.outputs.token }}
35+
path: ./.github/actions/wait-for-netlify-deploy
36+
37+
- name: Wait for Netlify Deploy
38+
id: deploy
39+
uses: ./.github/actions/wait-for-netlify-deploy
40+
with:
41+
site-name: netlify-plugin-nextjs-static-root-demo
42+
timeout: 300
43+
44+
- name: Deploy successful
45+
if: ${{ steps.deploy.outputs.origin-url }}
46+
run: echo ${{ steps.deploy.outputs.origin-url }}
47+
48+
- name: Node
49+
uses: actions/setup-node@v2
50+
with:
51+
node-version: '16'
52+
53+
- run: npm install
54+
55+
- name: Cypress run
56+
if: ${{ steps.deploy.outputs.origin-url }}
57+
id: cypress
58+
uses: cypress-io/github-action@v2
59+
with:
60+
browser: chrome
61+
headless: true
62+
record: true
63+
parallel: true
64+
config-file: cypress/config/static-root.json
65+
env:
66+
DEBUG: '@cypress/github-action'
67+
CYPRESS_baseUrl: ${{ steps.deploy.outputs.origin-url }}
68+
CYPRESS_NETLIFY_CONTEXT: ${{ steps.deploy.outputs.context }}
69+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
70+
CYPRESS_RECORD_KEY: ${{ secrets.STATIC_CYPRESS_RECORD_KEY }}

.github/workflows/cypress-demo.yml

Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
name: Run e2e
2+
on:
3+
pull_request:
4+
types: [opened, labeled, unlabeled, synchronize]
5+
push:
6+
branches:
7+
- main
8+
paths:
9+
- 'demos/default/**/*.{js,jsx,ts,tsx}'
10+
- 'cypress/integration/default/**/*.{ts,js}'
11+
- 'src/**/*.{ts,js}'
12+
jobs:
13+
cypress:
14+
runs-on: ubuntu-latest
15+
strategy:
16+
fail-fast: false
17+
matrix:
18+
containers: [1, 2, 3, 4, 5, 6]
19+
steps:
20+
- name: Checkout
21+
uses: actions/checkout@v2
22+
23+
- name: Generate Github token
24+
uses: navikt/github-app-token-generator@v1
25+
id: get-token
26+
with:
27+
private-key: ${{ secrets.TOKENS_PRIVATE_KEY }}
28+
app-id: ${{ secrets.TOKENS_APP_ID }}
29+
30+
- name: Checkout @netlify/wait-for-deploy-action
31+
uses: actions/checkout@v2
32+
with:
33+
repository: netlify/wait-for-deploy-action
34+
token: ${{ steps.get-token.outputs.token }}
35+
path: ./.github/actions/wait-for-netlify-deploy
36+
37+
- name: Wait for Netlify Deploy
38+
id: deploy
39+
uses: ./.github/actions/wait-for-netlify-deploy
40+
with:
41+
site-name: netlify-plugin-nextjs-demo
42+
timeout: 300
43+
44+
- name: Deploy successful
45+
if: ${{ steps.deploy.outputs.origin-url }}
46+
run: echo ${{ steps.deploy.outputs.origin-url }}
47+
48+
- name: Node
49+
uses: actions/setup-node@v2
50+
with:
51+
node-version: '16'
52+
53+
- run: npm install
54+
55+
- name: Cypress run
56+
if: ${{ steps.deploy.outputs.origin-url }}
57+
id: cypress
58+
uses: cypress-io/github-action@v2
59+
with:
60+
browser: chrome
61+
headless: true
62+
record: true
63+
parallel: true
64+
config-file: cypress/config/ci.json
65+
env:
66+
DEBUG: '@cypress/github-action'
67+
CYPRESS_baseUrl: ${{ steps.deploy.outputs.origin-url }}
68+
CYPRESS_NETLIFY_CONTEXT: ${{ steps.deploy.outputs.context }}
69+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
70+
CYPRESS_RECORD_KEY: ${{ secrets.DEFAULT_CYPRESS_RECORD_KEY }}

CHANGELOG.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,12 @@
11
# Changelog
22

3+
## [4.2.0](https://www.github.com/netlify/netlify-plugin-nextjs/compare/v4.1.3...v4.2.0) (2022-01-17)
4+
5+
6+
### Features
7+
8+
* add request logging ([#1127](https://www.github.com/netlify/netlify-plugin-nextjs/issues/1127)) ([010e86c](https://www.github.com/netlify/netlify-plugin-nextjs/commit/010e86c7c7513df8676dd8b3c747dcfa81fbc09e))
9+
310
### [4.1.3](https://www.github.com/netlify/netlify-plugin-nextjs/compare/v4.1.2...v4.1.3) (2022-01-13)
411

512

README.md

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,12 @@ npm install -D @netlify/plugin-nextjs
3131
package = "@netlify/plugin-nextjs"
3232
```
3333

34+
## Deploying
35+
36+
If you build on Netlify, this plugin will work with no additional configuration. However if you are building and
37+
deploying locally using the Netlify CLI, you must deploy using `netlify deploy --build`. Running the
38+
build and deploy commands separately will not work, because the plugin will not generate the required configuration.
39+
3440
## Migrating from an older version of the plugin
3541

3642
You can manually upgrade from the previous version of the plugin by running the following command:
@@ -58,7 +64,8 @@ it.
5864

5965
If you currently use redirects or rewrites on your site, see
6066
[the Rewrites and Redirects guide](https://github.com/netlify/netlify-plugin-nextjs/blob/main/docs/redirects-rewrites.md)
61-
for information on changes to how they are handled in this version.
67+
for information on changes to how they are handled in this version. In particular, note that `_redirects` and `_headers`
68+
files must be placed in `public`, not in the root of the site.
6269

6370
If you want to use Next 12's beta Middleware feature, this will mostly work as expected but please
6471
[read the docs on some caveats and workarounds](https://github.com/netlify/netlify-plugin-nextjs/blob/main/docs/middleware.md)
@@ -85,6 +92,20 @@ you can remove it. Alternatively you can
8592
support. See [`demos/next-export`](https://github.com/netlify/netlify-plugin-nextjs/tree/main/demos/next-export) for an
8693
example.
8794

95+
## Asset optimization
96+
97+
Netlify [asset optimization](https://docs.netlify.com/site-deploys/post-processing/) should not be used with Next.js
98+
sites. Assets are already optimized by Next.js at build time, and doing further optimization can break your site. Ensure
99+
that it is not enabled at **Site settings > Build & deploy > Post processing > Asset optimization**.
100+
101+
## Generated functions
102+
103+
This plugin works by generating three Netlify functions that handle requests that haven't been pre-rendered. These are
104+
`___netlify-handler` (for SSR and API routes), `___netlify-odb-handler` (for ISR and fallback routes), and `_ipx` (for
105+
images). You can see the requests for these in [the function logs](https://docs.netlify.com/functions/logs/). For ISR
106+
and fallback routes you will not see any requests that are served from the edge cache, just actual rendering requests.
107+
These are all internal functions, so you won't find them in your site's own functions directory.
108+
88109
## Feedback
89110

90111
If you think you have found a bug in the plugin,

cypress/config/ci.json

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,5 @@
11
{
22
"baseUrl": "http://localhost:3000",
3-
"integrationFolder": "../../cypress/integration/default",
4-
"pluginsFile": "../../cypress/plugins",
5-
"screenshotsFolder": "../../cypress/screenshots",
6-
"supportFile": "../../cypress/support/index.js",
7-
"videoFolder": "../../cypress/videos",
3+
"integrationFolder": "cypress/integration/default",
84
"projectId": "66va58"
95
}

cypress/config/nx-demo.json

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,5 @@
11
{
22
"baseUrl": "http://localhost:4200",
3-
"integrationFolder": "../../cypress/integration/nx",
4-
"pluginsFile": "../../cypress/plugins",
5-
"screenshotsFolder": "../../cypress/screenshots",
6-
"supportFile": "../../cypress/support/index.js",
7-
"videoFolder": "../../cypress/videos",
3+
"integrationFolder": "cypress/integration/nx",
84
"projectId": "ijcdpo"
95
}

cypress/config/static-root.json

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,5 @@
11
{
22
"baseUrl": "http://localhost:3000",
3-
"integrationFolder": "../../cypress/integration/static-root",
4-
"pluginsFile": "../../cypress/plugins",
5-
"screenshotsFolder": "../../cypress/screenshots",
6-
"supportFile": "../../cypress/support/index.js",
7-
"videoFolder": "../../cypress/videos",
3+
"integrationFolder": "cypress/integration/static-root",
84
"projectId": "3tvrbe"
95
}

cypress/integration/default/default.spec.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ describe('Default site', () => {
44
})
55

66
it('loads home page', () => {
7-
cy.findByText('Next Demo!')
7+
cy.findByText('NextJS on Netlify (imported Header component)')
88
cy.findByTestId('list-server-side').within(() => {
99
cy.findAllByRole('link').should('have.length', 5)
1010
})

cypress/integration/default/rewrites-redirects.spec.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ describe('Rewrites and Redirects', () => {
22
it('rewrites: points /old to /', () => {
33
// preview mode is off by default
44
cy.visit('/old')
5-
cy.findByText('Next Demo!')
5+
cy.findByText('NextJS on Netlify (imported Header component)')
66
cy.url().should('eq', `${Cypress.config().baseUrl}/old/`)
77

88
// ensure headers are still set

cypress/integration/default/test.spec.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,6 @@ describe('TypeScript spec', () => {
44
})
55

66
it('loads home page', () => {
7-
cy.findByText('Next Demo!')
7+
cy.findByText('NextJS on Netlify (imported Header component)')
88
})
99
})

demos/default/components/Header.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
export default function Header() {
2-
return <h1>Next Demo!</h1>
2+
return <h1>NextJS on Netlify (imported Header component)</h1>
33
}

demos/default/netlify.toml

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -17,11 +17,4 @@ framework = "#static"
1717
package = "./local-plugin"
1818

1919
[[plugins]]
20-
package = "@netlify/plugin-local-install-core"
21-
22-
[[context.deploy-preview.plugins]]
23-
package = "netlify-plugin-cypress"
24-
25-
[context.deploy-preview.plugins.inputs]
26-
record = true
27-
configFile = "../../cypress/config/ci.json"
20+
package = "@netlify/plugin-local-install-core"

demos/default/pages/_app.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,11 @@
11
import '../styles/globals.css'
22

33
function MyApp({ Component, pageProps }) {
4-
return <Component {...pageProps} />
4+
return (
5+
<div className='prose ml-14 mt-10 mb-20'>
6+
<Component {...pageProps} />
7+
</div>
8+
)
59
}
610

711
export default MyApp

0 commit comments

Comments
 (0)