Untitled
unknown
javascript
2 months ago
3.7 kB
107
Indexable
const withBundleAnalyzer = require('@next/bundle-analyzer')({
enabled: process.env.ANALYZE === 'true',
});
const defaultConfig = {
poweredByHeader: false,
transpilePackages: ['geist'],
images: {
formats: ['image/avif', 'image/webp'],
remotePatterns: [
{
protocol: 'https',
hostname: '**',
},
],
},
async headers() {
return [
{
source: '/',
headers: [
{
key: 'Cache-Control',
value: 'max-age=0, s-maxage=31536000',
},
],
},
{
source: '/home',
headers: [
{
key: 'Cache-Control',
value: 'max-age=0, s-maxage=31536000',
},
],
},
{
source: '/fonts/:slug*',
headers: [
{
key: 'Cache-Control',
value: 'public, max-age=31536000, immutable',
},
],
},
{
source: '/:all*(svg|jpg|png)',
locale: false,
headers: [
{
key: 'Cache-Control',
value: 'public, max-age=31536000, must-revalidate',
},
],
},
{
source: '/animations/:all*',
headers: [
{
key: 'Cache-Control',
value: 'public, max-age=31536000, immutable',
},
],
},
{
source: '/videos/:all*',
headers: [
{
key: 'Cache-Control',
value: 'public, max-age=31536000, immutable',
},
],
},
{
source: '/images/technology-logos/:all*',
headers: [
{
key: 'Cache-Control',
value: 'public, max-age=0, must-revalidate',
},
],
},
];
},
async redirects() {
return [
{
source: '/home',
destination: '/',
permanent: true,
},
];
},
webpack(config) {
const fileLoaderRule = config.module.rules.find((rule) => rule.test?.test?.('.svg'));
config.module.rules.push(
// Reapply the existing rule, but only for svg imports not ending in ".inline.svg"
{
test: /(?<!inline)\.svg$/,
use: [
{
loader: require.resolve('url-loader'),
options: {
limit: 512,
publicPath: '/_next/static/svgs',
outputPath: 'static/svgs',
fallback: require.resolve('file-loader'),
},
},
{
loader: require.resolve('svgo-loader'),
},
],
},
// Convert all other *.svg imports to React components
{
test: /\.inline.svg$/i,
use: [
{
loader: '@svgr/webpack',
options: {
svgo: true,
svgoConfig: {
plugins: [
{
name: 'preset-default',
params: {
overrides: {
removeViewBox: false,
},
},
},
'prefixIds',
],
},
},
},
],
}
);
// Modify the file loader rule to ignore *.svg, since we have it handled now.
fileLoaderRule.exclude = /\.svg$/i;
config.resolve.fallback = {
...config.resolve.fallback,
fs: false,
module: false,
path: false,
crypto: false,
stream: false,
assert: false,
http: false,
https: false,
os: false,
url: false,
};
return config;
},
};
module.exports = withBundleAnalyzer(defaultConfig);
Editor is loading...
Leave a Comment