2023-10-18 04:26:20 +00:00
|
|
|
// @ts-check
|
2023-05-25 04:58:35 +00:00
|
|
|
const { withContentlayer } = require('next-contentlayer');
|
2023-10-16 04:28:16 +00:00
|
|
|
const withBundleAnalyzer = require('@next/bundle-analyzer')({
|
|
|
|
enabled: process.env.ANALYZE === 'true'
|
|
|
|
});
|
2023-10-25 19:52:18 +00:00
|
|
|
const { withPlausibleProxy } = require('next-plausible');
|
2023-05-25 04:58:35 +00:00
|
|
|
|
|
|
|
// Validate env on build // TODO: I wish we could do this so Vercel can warn us when we are wrong but it's too hard.
|
|
|
|
// import './src/env.mjs';
|
2023-05-21 13:11:03 +00:00
|
|
|
|
|
|
|
/** @type {import('next').NextConfig} */
|
|
|
|
const nextConfig = {
|
|
|
|
reactStrictMode: true,
|
|
|
|
swcMinify: true,
|
|
|
|
transpilePackages: ['@sd/ui'],
|
2023-10-16 04:28:16 +00:00
|
|
|
eslint: {
|
|
|
|
ignoreDuringBuilds: true
|
|
|
|
},
|
|
|
|
typescript: {
|
|
|
|
ignoreBuildErrors: true
|
|
|
|
},
|
|
|
|
experimental: {
|
|
|
|
optimizePackageImports: ['@sd/ui']
|
|
|
|
},
|
2023-10-18 04:26:20 +00:00
|
|
|
headers: async () => [
|
|
|
|
{
|
|
|
|
source: '/api/:path*',
|
|
|
|
headers: [
|
|
|
|
{
|
|
|
|
key: 'Access-Control-Allow-Origin',
|
|
|
|
value: '*'
|
|
|
|
},
|
|
|
|
{
|
|
|
|
key: 'Access-Control-Allow-Methods',
|
|
|
|
value: 'GET, HEAD, OPTIONS'
|
|
|
|
},
|
|
|
|
{
|
|
|
|
key: 'Access-Control-Allow-Headers',
|
|
|
|
value: 'Content-Type'
|
|
|
|
}
|
|
|
|
]
|
|
|
|
}
|
|
|
|
],
|
2023-05-21 13:11:03 +00:00
|
|
|
webpack(config) {
|
|
|
|
// Grab the existing rule that handles SVG imports
|
|
|
|
const fileLoaderRule = config.module.rules.find((rule) => rule.test?.test?.('.svg'));
|
|
|
|
|
|
|
|
config.module.rules.push(
|
|
|
|
// Reapply the existing rule, but only for svg imports ending in ?url
|
|
|
|
{
|
|
|
|
...fileLoaderRule,
|
|
|
|
test: /\.svg$/i,
|
|
|
|
resourceQuery: /url/ // *.svg?url
|
|
|
|
},
|
|
|
|
// Convert all other *.svg imports to React components so it's compatible with Vite's plugin.
|
|
|
|
{
|
|
|
|
test: /\.svg$/i,
|
2023-10-24 07:51:58 +00:00
|
|
|
issuer: { not: /\.(css|scss|sass)$/ },
|
2023-05-21 13:11:03 +00:00
|
|
|
resourceQuery: { not: /url/ }, // exclude if *.svg?url
|
|
|
|
use: [
|
|
|
|
{
|
|
|
|
loader: '@svgr/webpack',
|
2023-05-26 15:57:56 +00:00
|
|
|
options: {
|
|
|
|
icon: true,
|
|
|
|
exportType: 'named',
|
|
|
|
typescript: true,
|
|
|
|
svgProps: { fill: 'currentColor' }
|
|
|
|
}
|
2023-05-21 13:11:03 +00:00
|
|
|
}
|
|
|
|
]
|
|
|
|
}
|
|
|
|
);
|
|
|
|
|
|
|
|
// Modify the file loader rule to ignore *.svg, since we have it handled now.
|
|
|
|
fileLoaderRule.exclude = /\.svg$/i;
|
|
|
|
|
|
|
|
return config;
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2023-10-25 19:52:18 +00:00
|
|
|
module.exports = withPlausibleProxy()(withBundleAnalyzer(withContentlayer(nextConfig)));
|