-
-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathnext.config.mjs
42 lines (35 loc) · 1.03 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
import {execSync} from 'child_process';
import path from 'path';
import {fileURLToPath} from 'url';
import fs from 'fs';
const __filename = fileURLToPath(import.meta.url);
const __dirname = path.dirname(__filename);
const LOCK_FILE = path.join(__dirname, '.prepare-images-lock');
/** @type {import('next').NextConfig} */
const nextConfig = {
reactStrictMode: true,
webpack: (config, {dev, isServer}) => {
if (!dev && isServer) {
// Check if we've already run the script
if (!fs.existsSync(LOCK_FILE)) {
console.log("Running prepare-images script...");
execSync('npm run prepare-images', {stdio: 'inherit'});
// Create a lock file to indicate the script has run
fs.writeFileSync(LOCK_FILE, 'locked');
}
}
return config;
},
transpilePackages: ['next-mdx-remote'],
images: {
remotePatterns: [
{
protocol: 'http',
hostname: 'localhost',
port: '3000',
pathname: '**/placeholder-image.png',
},
],
},
};
export default nextConfig;