Skip to content

Commit

Permalink
Chore nextjs 15 & more (#71)
Browse files Browse the repository at this point in the history
* Update package.json to nextjs 15, eslint 9 and more

* err & error no-unused-vars

* Fix mdx-js breaking change due to package.json update

* removeViewBox, removeUselessStrokeAndFill are now set to false for @svgr/webpack

* In React 18, SSRProvider is not necessary and is a noop. You can remove it from your app.

* More package.json updates

* Fix runtime value

* nextjs 15.1.0

* These settings are included ^15.1.0 already

* Update react deps

* Update builder.io/react dep

* Revalidate 30->60

* Revert some changes based on main

* Next 15.1.2

* Related 3418017

* Related 6d9e201

* Update bp menu
  • Loading branch information
catalinred authored Dec 19, 2024
1 parent d03a27b commit 245e969
Show file tree
Hide file tree
Showing 45 changed files with 3,794 additions and 3,989 deletions.
2 changes: 1 addition & 1 deletion assets/podcast/background-art.inline.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion next-env.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@
/// <reference types="next/navigation-types/compat/navigation" />

// NOTE: This file should not be edited
// see https://nextjs.org/docs/app/building-your-application/configuring/typescript for more information.
// see https://nextjs.org/docs/app/api-reference/config/typescript for more information.
306 changes: 165 additions & 141 deletions next.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,152 +36,176 @@ if (process.env.NEXT_PUBLIC_VERCEL_ENV === "preview") {
});
}

const moduleExports = () => {
const plugins = [
withBundleAnalyzer({ enabled: process.env.ANALYZE === "true" }),
];
return plugins.reduce((acc, next) => next(acc), {
i18n,
reactStrictMode: true,
swcMinify: true,
productionBrowserSourceMaps: true,
async rewrites() {
return rewritesAndRedirectsJson.rewrites;
},
async redirects() {
const existingRedirects = [
{
source: "/news/tag/:tag*/page/:page*",
destination: `/news/tag/:tag*`,
permanent: true,
},
{
source: "/news/tag",
destination: `/news`,
permanent: true,
},
{
source: "/news/page",
destination: `/news`,
permanent: true,
},
...rewritesAndRedirectsJson.redirects.map((redirect) => ({
...redirect,
// @ts-ignore
permanent: redirect.permanent ?? true,
})),
];
const nextConfig = {
i18n,
reactStrictMode: true,
productionBrowserSourceMaps: true,

try {
return builder
.getAll("url-redirects", {
apiKey:
process.env.NEXT_PUBLIC_BUILDER_API_KEY ||
"ce0c7323a97a4d91bd0baa7490ec9139",
options: { noTargeting: true },
cachebust: true,
})
.then((results) => {
try {
return [
...existingRedirects,
...results
.filter((content) => {
const data = (content || {}).data || {};
return !!(data.sourceUrl && data.destinationUrl);
})
.map(({ data }) => ({
source: data.sourceUrl,
destination: data.destinationUrl,
permanent: !!data.permanentRedirect,
})),
];
} catch (error) {
console.log("Error processing redirects", error);
return existingRedirects;
}
})
.catch((error) => {
console.log("Error setting up redirects", error);
return existingRedirects;
});
} catch (error) {
console.log("Error fetching redirects from Builder:", error);
return existingRedirects;
}
},
webpack(config) {
config.module.rules.push({
test: /\.inline\.svg$/,
exclude: /node_modules/,
loader: "svg-react-loader",
});
async rewrites() {
return rewritesAndRedirectsJson.rewrites;
},

const imageLoaderRule = config.module.rules.find(
(rule) => rule.loader == "next-image-loader",
);
imageLoaderRule.exclude = /\.inline\.svg$/;
async redirects() {
const existingRedirects = [
{
source: "/news/tag/:tag*/page/:page*",
destination: `/news/tag/:tag*`,
permanent: true,
},
{
source: "/news/tag",
destination: `/news`,
permanent: true,
},
{
source: "/news/page",
destination: `/news`,
permanent: true,
},
...rewritesAndRedirectsJson.redirects.map((redirect) => ({
...redirect,
permanent: redirect.permanent ?? true,
})),
];

return config;
},
try {
return builder
.getAll("url-redirects", {
apiKey:
process.env.NEXT_PUBLIC_BUILDER_API_KEY ||
"ce0c7323a97a4d91bd0baa7490ec9139",
options: { noTargeting: true },
cachebust: true,
})
.then((results) => {
try {
return [
...existingRedirects,
...results
.filter((content) => {
const data = (content || {}).data || {};
return !!(data.sourceUrl && data.destinationUrl);
})
.map(({ data }) => ({
source: data.sourceUrl,
destination: data.destinationUrl,
permanent: !!data.permanentRedirect,
})),
];
} catch (error) {
console.log("Error processing redirects", error);
return existingRedirects;
}
})
.catch((error) => {
console.log("Error setting up redirects", error);
return existingRedirects;
});
} catch (error) {
console.log("Error fetching redirects from Builder:", error);
return existingRedirects;
}
},

images: {
remotePatterns: [
{
protocol: "https",
hostname: "i.ytimg.com",
},
{
protocol: "https",
hostname: "img.youtube.com",
},
{
protocol: "https",
hostname: "**.gstatic.com",
},
{
protocol: "https",
hostname: "**.lumacdn.com",
},
{
protocol: "https",
hostname: "**.lu.ma",
},
{
protocol: "https",
hostname: "cdn.builder.io",
},
{
protocol: "https",
hostname: "solana-developer-content.vercel.app",
},
{
protocol: "https",
hostname: "images.unsplash.com",
},
{
protocol: "https",
hostname: "assets.getriver.io",
webpack(config) {
config.module.rules.push({
test: /\.svg$/,
use: {
loader: "@svgr/webpack",
options: {
svgoConfig: {
plugins: [
{
name: "preset-default",
params: {
overrides: {
removeViewBox: false,
removeUselessStrokeAndFill: false,
},
},
},
],
},
},
],
},
compiler: {
// ssr and displayName are configured by default
styledComponents: true,
},
async headers() {
return [
{
// Apply headers to all routes
source: "/:path*",
headers: securityHeaders,
},
];
},
experimental: {
scrollRestoration: true,
},
});

return config;
},

images: {
remotePatterns: [
{
protocol: "https",
hostname: "i.ytimg.com",
},
{
protocol: "https",
hostname: "img.youtube.com",
},
{
protocol: "https",
hostname: "**.gstatic.com",
},
{
protocol: "https",
hostname: "**.lumacdn.com",
},
{
protocol: "https",
hostname: "**.lu.ma",
},
{
protocol: "https",
hostname: "cdn.builder.io",
},
{
protocol: "https",
hostname: "solana-developer-content.vercel.app",
},
{
protocol: "https",
hostname: "images.unsplash.com",
},
{
protocol: "https",
hostname: "assets.getriver.io",
},
],
},

compiler: {
styledComponents: true,
},

async headers() {
return [
{
source: "/:path*",
headers: securityHeaders,
},
];
},

experimental: {
scrollRestoration: true,
},

// Ignore deprecation warnings and mixed declaration warnings
// https://github.com/vercel/next.js/issues/71638
sassOptions: {
logger: {
warn: function (message) {
if (
message.includes("deprecat") ||
message.includes("declarations that appear after nested")
)
return;
console.warn(message);
},
},
});
},
};

module.exports = moduleExports;
module.exports =
process.env.ANALYZE === "true" ? withBundleAnalyzer(nextConfig) : nextConfig;
Loading

0 comments on commit 245e969

Please sign in to comment.