Repository navigation
Expand file tree
/
Copy pathnext.config.mjs
More file actions
88 lines (83 loc) · 2.69 KB
/
Copy pathnext.config.mjs
File metadata and controls
88 lines (83 loc) · 2.69 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
/**
* Run `build` or `dev` with `SKIP_ENV_VALIDATION` to skip env validation. This is especially useful
* for Docker builds.
*/
await import("./src/server/env/index.mjs");
import withBundleAnalyzer from "@next/bundle-analyzer";
import setupSerwist from "@serwist/next";
import setupNextRoutes from "nextjs-routes/config";
import { FileSystemIconLoader } from "unplugin-icons/loaders";
import unpluginIcons from "unplugin-icons/webpack";
import { authRoutesPlugin } from "./webpack/auth-routes.mjs";
const withRoutes = setupNextRoutes();
const withSerwistInit = setupSerwist({
swDest: "public/recallio-sw.js",
swUrl: "recallio-sw.js",
swSrc: "./src/sw/index.ts",
reloadOnOnline: false,
register: false,
});
/** @type {import("next").NextConfig} */
const config = {
swcMinify: true,
reactStrictMode: true,
redirects() {
return Promise.resolve([{ source: "/", destination: "/scan", permanent: true }]);
},
/**
* If you are using `appDir` then you must comment the below `i18n` config out.
*
* @see https://github.com/vercel/next.js/issues/41980
*/
i18n: {
locales: ["en"],
defaultLocale: "en",
},
images: {
remotePatterns: [
{ hostname: "avatars.githubusercontent.com", pathname: "/u/*" },
{ hostname: "cdn.discordapp.com", pathname: "/avatars/*" },
{ hostname: "*.googleusercontent.com", pathname: "/a/*" },
{ hostname: "media.licdn.com", pathname: "**" },
{ hostname: "uploadthing.com", pathname: "/f/**" },
{ hostname: "utfs.io", pathname: "/f/**" },
{ hostname: "picsum.photos", pathname: "/seed/**" },
{ hostname: "loremflickr.com" },
{ hostname: "cloudflare-ipfs.com", pathname: "/ipfs/**" },
],
},
/**
* @param {import("webpack").Configuration} config
* @returns {import("webpack").Configuration}
*/
webpack(config, ctx) {
config.plugins ??= [];
config.plugins.push(
// eslint-disable-next-line @typescript-eslint/no-unsafe-argument
unpluginIcons({
compiler: "jsx",
jsx: "react",
autoInstall: true,
scale: 1,
customCollections: {
custom: FileSystemIconLoader("./src/assets/icons"),
},
}),
);
// can't run this during build because type-checking will fail before this plugin does its job
// this plugin is executed in `prebuild` script instead
if (ctx.dev) {
config.plugins.push(authRoutesPlugin(ctx.dev));
}
return config;
},
experimental: {
esmExternals: false,
},
typescript: { ignoreBuildErrors: !!process.env.NO_TSC },
};
export default function NextConfig() {
return withSerwistInit(
withRoutes(withBundleAnalyzer({ enabled: process.env.ANALYZE === "true" })(config)),
);
}