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

Chore nextjs 15 #71

Merged
merged 20 commits into from
Dec 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
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
Loading