2022-12-31 06:29:41 +00:00
|
|
|
/** @type {import('next').NextConfig} */
|
2022-12-31 11:44:19 +00:00
|
|
|
|
2023-03-18 02:34:07 +00:00
|
|
|
const { withSentryConfig } = require('@sentry/nextjs')
|
|
|
|
|
2022-12-31 11:44:19 +00:00
|
|
|
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 11:44:19 +00:00
|
|
|
|
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,
|
2022-12-31 11:44:19 +00:00
|
|
|
},
|
|
|
|
|
2023-03-18 02:34:07 +00:00
|
|
|
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,
|
|
|
|
},
|
|
|
|
|
2022-12-31 11:44:19 +00:00
|
|
|
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*`,
|
|
|
|
}]
|
|
|
|
|
2023-02-11 13:14:14 +00:00
|
|
|
const badgeRedirects = [
|
2023-01-14 14:34:10 +00:00
|
|
|
{ source: '/badge/:path*', destination: '/api/static' },
|
2023-02-05 11:20:03 +00:00
|
|
|
{ source: '/badge', destination: '/api/static' },
|
2023-02-11 13:14:14 +00:00
|
|
|
]
|
2023-02-05 11:20:03 +00:00
|
|
|
|
2023-02-11 13:14:14 +00:00
|
|
|
const badgeApis = [
|
|
|
|
'/static',
|
2023-03-18 02:53:04 +00:00
|
|
|
'/github',
|
2023-07-25 15:24:30 +00:00
|
|
|
'/gitlab',
|
2023-07-26 12:17:48 +00:00
|
|
|
'/https',
|
2023-07-02 11:57:22 +00:00
|
|
|
// registry
|
2023-07-02 00:01:52 +00:00
|
|
|
'/amo',
|
2023-06-10 01:25:28 +00:00
|
|
|
'/npm',
|
2023-06-28 08:40:09 +00:00
|
|
|
'/crates',
|
2023-07-02 11:57:22 +00:00
|
|
|
'/winget',
|
2023-07-28 14:35:25 +00:00
|
|
|
'/docker',
|
2023-06-10 01:49:24 +00:00
|
|
|
'/chrome-web-store',
|
2023-07-02 00:15:06 +00:00
|
|
|
'/vs-marketplace',
|
2023-06-10 03:11:10 +00:00
|
|
|
'/hackage',
|
2023-06-10 07:44:37 +00:00
|
|
|
'/ppm',
|
2023-06-10 02:37:06 +00:00
|
|
|
'/pypi',
|
2023-07-02 11:57:22 +00:00
|
|
|
// analysis
|
|
|
|
'/bundlephobia',
|
|
|
|
'/packagephobia',
|
|
|
|
'/codeclimate',
|
|
|
|
'/codecov',
|
|
|
|
'/travis',
|
2023-02-11 13:14:14 +00:00
|
|
|
'/xo',
|
2023-07-02 11:57:22 +00:00
|
|
|
// social network
|
|
|
|
'/discord',
|
|
|
|
'/matrix',
|
|
|
|
'/runkit',
|
2023-07-09 09:52:24 +00:00
|
|
|
'/peertube',
|
2023-06-10 07:27:32 +00:00
|
|
|
// discontinued
|
|
|
|
'/apm',
|
2023-06-19 07:51:39 +00:00
|
|
|
'/lgtm',
|
2023-06-22 06:57:25 +00:00
|
|
|
'/david',
|
2023-01-14 14:34:10 +00:00
|
|
|
]
|
2023-02-11 13:14:14 +00:00
|
|
|
|
2023-03-18 06:46:49 +00:00
|
|
|
badgeApis.forEach(badge => {
|
|
|
|
badgeRedirects.push({ source: `${badge}/:path*`, destination: `/api${badge}` }) // badges
|
|
|
|
badgeRedirects.push({ source: badge, destination: `/api${badge}` }) // doc pages
|
2023-02-11 13:14:14 +00:00
|
|
|
})
|
|
|
|
|
|
|
|
// const badgeRedirects = liveBadgeRedirects.concat(staticBadgeRedirects)
|
|
|
|
|
|
|
|
return badgeRedirects
|
2022-12-31 11:44:19 +00:00
|
|
|
},
|
2019-05-26 04:41:21 +00:00
|
|
|
}
|
2022-12-31 06:29:41 +00:00
|
|
|
|
2023-03-18 02:34:07 +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
|
2023-03-18 05:20:18 +00:00
|
|
|
dryRun: process.env.VERCEL_ENV !== "production"
|
|
|
|
|
2023-03-18 02:34:07 +00:00
|
|
|
// For all available options, see:
|
|
|
|
// https://github.com/getsentry/sentry-webpack-plugin#options.
|
|
|
|
}
|
|
|
|
|
|
|
|
module.exports = withSentryConfig(nextConfig, sentryWebpackPluginOptions)
|