Configuration of webpack dynamic entry

my entry is read through file and is an asynchronous operation. I don"t know how to introduce it into webpack.config now. The
code thanks everyone

at this address https://github.com/chenqing20.
.
Feb.24,2022

you can try this by first exposing the readFile method directly in config.js

module.exports = readFile;

modify webpack.config.js at the same time

var readFile = require("./config");
var path = require("path");
var distPath = path.join(__dirname, "/dist/");

module.exports = async function() {
  var entry = await readFile();
  return {
    entry: entry,
    output: {
      filename: "[name].js",
      path: distPath
    },
    module: {
      rules: [
        {
          test: /\.m?js$/,
          exclude: /(node_modules)/,
          use: {
            loader: "babel-loader",
            options: {
              presets: ["@babel/preset-env"]
            }
          }
        }
      ]
    }
  };
};

Menu