chore(deps): update to next config to address build errors

This commit is contained in:
Gabe Kangas
2023-11-29 20:27:14 -08:00
parent 6d217b4f5a
commit 27c48c4068
2 changed files with 71 additions and 61 deletions

View File

@@ -2,7 +2,7 @@ const withLess = require('next-with-less');
const withBundleAnalyzer = require('@next/bundle-analyzer')({
enabled: process.env.ANALYZE === 'true',
});
const { PHASE_DEVELOPMENT_SERVER } = require('next/constants');
const runtimeCaching = require('next-pwa/cache');
const withPWA = require('next-pwa')({
@@ -31,57 +31,73 @@ const withPWA = require('next-pwa')({
disable: process.env.NODE_ENV === 'development',
});
module.exports = withPWA(
withBundleAnalyzer(
withLess({
productionBrowserSourceMaps: process.env.SOURCE_MAPS === 'true',
trailingSlash: true,
reactStrictMode: true,
images: {
unoptimized: true,
},
swcMinify: true,
output: 'export',
webpack(config) {
config.module.rules.push({
test: /\.svg$/i,
issuer: /\.[jt]sx?$/,
use: ['@svgr/webpack'],
});
async function rewrites() {
return [
{
source: '/api/:path*',
destination: 'http://localhost:8080/api/:path*', // Proxy to Backend to work around CORS.
},
{
source: '/hls/:path*',
destination: 'http://localhost:8080/hls/:path*', // Proxy to Backend to work around CORS.
},
{
source: '/img/:path*',
destination: 'http://localhost:8080/img/:path*', // Proxy to Backend to work around CORS.
},
{
source: '/logo',
destination: 'http://localhost:8080/logo', // Proxy to Backend to work around CORS.
},
{
source: '/thumbnail.jpg',
destination: 'http://localhost:8080/thumbnail.jpg', // Proxy to Backend to work around CORS.
},
{
source: '/customjavascript',
destination: 'http://localhost:8080/customjavascript', // Proxy to Backend to work around CORS.
},
];
}
return config;
},
async rewrites() {
return process.env.NODE_ENV === 'development'
? [
{
source: '/api/:path*',
destination: 'http://localhost:8080/api/:path*', // Proxy to Backend to work around CORS.
},
{
source: '/hls/:path*',
destination: 'http://localhost:8080/hls/:path*', // Proxy to Backend to work around CORS.
},
{
source: '/img/:path*',
destination: 'http://localhost:8080/img/:path*', // Proxy to Backend to work around CORS.
},
{
source: '/logo',
destination: 'http://localhost:8080/logo', // Proxy to Backend to work around CORS.
},
{
source: '/thumbnail.jpg',
destination: 'http://localhost:8080/thumbnail.jpg', // Proxy to Backend to work around CORS.
},
{
source: '/customjavascript',
destination: 'http://localhost:8080/customjavascript', // Proxy to Backend to work around CORS.
},
]
: null;
},
pageExtensions: ['tsx'],
}),
),
);
module.exports = async phase => {
/**
* @type {import('next').NextConfig}
*/
let nextConfig = withPWA(
withBundleAnalyzer(
withLess({
productionBrowserSourceMaps: process.env.SOURCE_MAPS === 'true',
trailingSlash: true,
reactStrictMode: true,
images: {
unoptimized: true,
},
swcMinify: true,
webpack(config) {
config.module.rules.push({
test: /\.svg$/i,
issuer: /\.[jt]sx?$/,
use: ['@svgr/webpack'],
});
return config;
},
pageExtensions: ['tsx'],
}),
),
);
if (phase === PHASE_DEVELOPMENT_SERVER) {
nextConfig = {
...nextConfig,
rewrites,
};
} else {
nextConfig = {
...nextConfig,
output: 'export',
};
}
return nextConfig;
};