-
Notifications
You must be signed in to change notification settings - Fork 0
/
next.config.mjs
53 lines (49 loc) · 1.39 KB
/
next.config.mjs
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
import { build } from "velite";
/**
* Run `build` or `dev` with `SKIP_ENV_VALIDATION` to skip env validation. This is especially useful
* for Docker builds.
*/
await import("./src/env.js");
const isProduction = process.env.NODE_ENV === "production";
/** @type {import("next").NextConfig} */
const config = {
eslint: {
ignoreDuringBuilds: isProduction,
},
images: {
remotePatterns: [
{
protocol: "https",
hostname: "icons.duckduckgo.com",
},
{
protocol: "https",
hostname: "i.scdn.co",
},
{
protocol: "https",
hostname: "images5.alphacoders.com",
},
{ protocol: "https", hostname: "pbs.twimg.com" },
{ protocol: "https", hostname: "abs.twimg.com" },
],
},
webpack: (config) => {
config.plugins.push(new VeliteWebpackPlugin());
return config;
},
};
class VeliteWebpackPlugin {
static started = false;
apply(/** @type {import('webpack').Compiler} */ compiler) {
// executed three times in nextjs
// twice for the server (nodejs / edge runtime) and once for the client
compiler.hooks.beforeCompile.tapPromise("VeliteWebpackPlugin", async () => {
if (VeliteWebpackPlugin.started) return;
VeliteWebpackPlugin.started = true;
const dev = compiler.options.mode === "development";
await build({ watch: dev, clean: !dev });
});
}
}
export default config;