/ next.config.js
next.config.js
 1  const webpack = require("webpack"); // Add this import
 2  
 3  // Load env from .env file
 4  const envList = require("dotenv").config().parsed;
 5  
 6  // Get version from package.json
 7  const { version } = require("./package.json");
 8  
 9  // Set default IC host based on DFX_NETWORK
10  // envList.NEXT_PUBLIC_IC_HOST =
11  //   envList.DFX_NETWORK === "ic" ? "https://ic0.app" : "http://localhost:8080";
12  
13  // console.log("network", envList.DFX_NETWORK);
14  
15  // Export Next.js configuration
16  module.exports = {
17    webpack: (config) => {
18      config.plugins.push(
19        new webpack.EnvironmentPlugin({
20          ...envList, // Add environment variables
21          NEXT_PUBLIC_VERSION: version, // Add the version variable
22        }),
23      );
24  
25      return config;
26    },
27    // Other Next.js configuration options
28    // ...
29  };