-
Notifications
You must be signed in to change notification settings - Fork 16
/
Copy pathnext.config.mjs
36 lines (34 loc) · 967 Bytes
/
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
/** @type {import('next').NextConfig} */
const nextConfig = {
webpack: function (config) {
config.plugins.push(new VeliteWebpackPlugin())
return config
},
images: {
remotePatterns: [
{
protocol: "https",
hostname: "i.ytimg.com",
},
{
protocol: "https",
hostname: "images.unsplash.com",
}
],
},
};
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'
const { build } = await import('velite')
await build({ watch: dev, clean: !dev })
})
}
}
export default nextConfig;