badgen.net/next.config.js

74 wiersze
2.1 KiB
JavaScript
Czysty Zwykły widok Historia

2022-12-31 06:29:41 +00:00
/** @type {import('next').NextConfig} */
const { withSentryConfig } = require('@sentry/nextjs')
const badgeList = require('./public/.meta/badges.json')
2022-12-31 06:29:41 +00:00
const nextConfig = {
reactStrictMode: true,
2023-01-04 01:31:10 +00:00
optimizeFonts: false,
2022-12-31 06:29:41 +00:00
experimental: {
2023-01-04 01:31:10 +00:00
appDir: false,
2022-12-31 06:29:41 +00:00
forceSwcTransforms: true,
},
sentry: {
// Use `hidden-source-map` rather than `source-map` as the Webpack `devtool`
// for client-side builds. (This will be the default starting in
// `@sentry/nextjs` version 8.0.0.) See
// https://webpack.js.org/configuration/devtool/ and
// https://docs.sentry.io/platforms/javascript/guides/nextjs/manual-setup/#use-hidden-source-map
// for more information.
hideSourceMaps: true,
},
async rewrites() {
const liveBadgeRedirects = badgeList.live.map(badge => {
return {
source: `/${badge.id}/:path*`,
destination: `/api/${badge.id}/:path*`,
}
})
const staticBadgeRedirects = [{
source: `/badge/:path*`,
destination: `/api/badge/:path*`,
}]
const badgeRedirects = [
{ source: '/badge/:path*', destination: '/api/static' },
2023-02-05 11:20:03 +00:00
{ source: '/badge', destination: '/api/static' },
]
2023-02-05 11:20:03 +00:00
const badgeApis = [
'/static',
'/winget',
'/xo',
]
badgeApis.forEach(b => {
badgeRedirects.push({ source: `${b}/:path*`, destination: `/api${b}` }) // badges
badgeRedirects.push({ source: b, destination: `/api${b}` }) // doc pages
})
// const badgeRedirects = liveBadgeRedirects.concat(staticBadgeRedirects)
return badgeRedirects
},
2019-05-26 04:41:21 +00:00
}
2022-12-31 06:29:41 +00:00
const sentryWebpackPluginOptions = {
// Additional config options for the Sentry Webpack plugin. Keep in mind that
// the following options are set automatically, and overriding them is not
// recommended:
// release, url, org, project, authToken, configFile, stripPrefix,
// urlPrefix, include, ignore
silent: true, // Suppresses all logs
// For all available options, see:
// https://github.com/getsentry/sentry-webpack-plugin#options.
}
module.exports = withSentryConfig(nextConfig, sentryWebpackPluginOptions)