-
Notifications
You must be signed in to change notification settings - Fork 3
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
Next.js + Vercel! ▲ #1
base: latest
Are you sure you want to change the base?
Conversation
…s), and adds Next.js `/news` base route.
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
@@ -1 +1 @@ | |||
v12.18.4 | |||
14 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The move to Next.js didn't require this. Running anything below Node 14 is painful on an M1 Mac, so it was bumped up.
.env.local
Outdated
|
||
NEXT_PUBLIC_SIMORGH_CSP_REPORTING_ENDPOINT=https://ws.bbc-reporting-api.app/report-endpoint | ||
|
||
NEXT_PUBLIC_SIMORGH_OPTIMIZELY_SDK_KEY=LptPKDnHyAFu9V12s5xCz |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
All of these env files moved from an envConfig
folder, got renamed to work with Next.js's dotenv convention, and all variables used on the client got prefixed with NEXT_PUBLIC_
.
{children} | ||
</Helmet> | ||
</Head> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Moved non-dynamic meta and links to _app.js
.
@@ -1,3 +1,3 @@ | |||
/* eslint-disable import/prefer-default-export */ | |||
|
|||
export scriptPropType from './scripts'; | |||
export { default as scriptPropType } from './scripts'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This was angry... In order to properly re-export an export, they needed to be wrapped in defaults
's.
export { default as vietnamese } from './svgs/vietnamese'; | ||
export { default as weather } from './svgs/weather'; | ||
export { default as yoruba } from './svgs/yoruba'; | ||
export { default as zhongwen } from './svgs/zhongwen'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These were angry... In order to properly re-export an export, they needed to be wrapped in defaults
's.
}; | ||
|
||
this.verbose = (event, message) => { | ||
fileLogger.log({ file, event, message }); | ||
// console.log({ file, event, message }); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Turned all of these into noops because:
- It was super noisy while doing development. It was hard to debug issues around all the logging.
- It was also logging to the filesystem via
fs
, which doesn't really work in Vercel land. If we really want to do this right, we'd setup a log drain.
|
||
return config; | ||
}, | ||
}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I know we wanted to do as little custom configuration here as possible, but there's a few things going on here that are unavoidable without massive changes to the project.
- Simorgh uses Emotion for styling, so that needs to be enabled.
- Simorgh uses custom import aliases (ie.
import ArticlePage from '#pages/ArticlePage/ArticlePage'
) to avoid dot pathing everything, so the Webpack config is enhanced to accommodate this. MomentTimezoneInclude
is a custom Webpack plugin written by the SImorgh team to limit the size of timezones included to reduce bundle size.- And
MomentTimezoneInclude
is why we need to disable lint during builds. It's a cyclical problem. We need Webpack to build the app, so the customMomentTimezoneInclude
runs to create thetz
directory with the outputted timezones that are imported by other files, but we cannot build the app until it passes lint because imports fail to findtz
files. This existing process would need to be modified to run before lint and before build (possibly as a separate script).
If anyone is looking to run this PR / branch locally, you'll need to create a
|
Published blog post with a walkthrough 👉 Migrating a large, open-source React application to Next.js and Vercel