Skip to content

Commit

Permalink
Revert "Use typescript for nextjs config"
Browse files Browse the repository at this point in the history
This reverts commit 19b47ed.
  • Loading branch information
narthur committed Dec 26, 2024
1 parent 19b47ed commit 7a90abe
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 273 deletions.
35 changes: 11 additions & 24 deletions next.config.ts → next.config.js
Original file line number Diff line number Diff line change
@@ -1,29 +1,18 @@
import { NextConfig } from 'next';
import nextPwa, { PWAConfig } from 'next-pwa';
import path from 'path';

const withPWA = nextPwa({
const withPWA = require('next-pwa')({
dest: 'public',
// WORKAROUND: https://github.com/shadowwalker/next-pwa/issues/288#issuecomment-955777098
buildExcludes: [/server\/middleware-manifest\.json$/],
});
const path = require('path');

type WithBundleAnalyzer = (config: PWAConfig) => NextConfig & PWAConfig;

const getBundleAnalyzer = async (): Promise<WithBundleAnalyzer> => {
if (process.env.ANALYZE === 'true') {
const { default: withBundleAnalyzer } = await import(
'@next/bundle-analyzer'
);
return withBundleAnalyzer() as unknown as WithBundleAnalyzer;
}
return (config) => config;
};
const withBundleAnalyzer = await getBundleAnalyzer();
const withBundleAnalyzer =
process.env.ANALYZE === 'true'
? require('@next/bundle-analyzer')()
: (x) => x;

const config: NextConfig = withBundleAnalyzer(
module.exports = withBundleAnalyzer(
withPWA({
async headers() {
headers() {
return [
{
source: '/apple-app-site-association',
Expand All @@ -46,7 +35,7 @@ const config: NextConfig = withBundleAnalyzer(
];
},
async redirects() {
const languagePrefixMap: Record<string, string> = {
const languagePrefixMap = {
english: 'en',
deutsch: 'de',
german: 'de',
Expand All @@ -63,7 +52,7 @@ const config: NextConfig = withBundleAnalyzer(
permanent: true,
})),
...Object.keys(languagePrefixMap).map((prefix) => ({
source: `/${prefix}/:path((?!podcasts/latest|sermons/podcasts/latest|sermones/podcasts/ultima|predications/podcasts/plusrecent).*)`,
source: `/${prefix}/:path((?!podcasts\/latest|sermons\/podcasts\/latest|sermones\/podcasts\/ultima|predications\/podcasts\/plusrecent).*)`,
destination: `/${languagePrefixMap[prefix]}/:path*`,
statusCode: 301,
})),
Expand Down Expand Up @@ -642,7 +631,7 @@ const config: NextConfig = withBundleAnalyzer(
},
];
},
webpack: (config, { dev }) => {
webpack: (config, { buildId, dev, isServer, defaultLoaders, webpack }) => {
config.module.rules.push({
test: /\.(graphql|gql)$/,
exclude: /node_modules/,
Expand Down Expand Up @@ -675,5 +664,3 @@ const config: NextConfig = withBundleAnalyzer(
},
}),
);

export default config;
251 changes: 6 additions & 245 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 1 addition & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,6 @@
"@types/jest-when": "^3.5.5",
"@types/js-cookie": "^3.0.6",
"@types/lodash": "^4.17.7",
"@types/next-pwa": "^5.6.9",
"@types/node": "^22.10.2",
"@types/node-forge": "^1.3.11",
"@types/react": "^18.3.8",
Expand Down Expand Up @@ -167,4 +166,4 @@
"engines": {
"node": "20.17.0"
}
}
}
4 changes: 2 additions & 2 deletions tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
{
"compilerOptions": {
"module": "esnext",
"module": "commonjs",
"declaration": true,
"removeComments": true,
"emitDecoratorMetadata": true,
"experimentalDecorators": true,
"allowSyntheticDefaultImports": true,
"target": "esnext",
"target": "es6",
"lib": ["es2017", "es2019", "dom"],
"sourceMap": true,
"outDir": "./dist",
Expand Down

0 comments on commit 7a90abe

Please sign in to comment.