How does webpack modify the entry file dynamically?

//webpack.config.js
module.exports = {
    entry: {
        index: "./index.js"
    },
    output: {
        filename: "[name].js"
    }
};

as shown above, the entry file is index.js , and there are main.css , logo.png and other files in the same level directory of index.js . Now you need to require other files in index.js and compile webpack and finally package them into a file:

//index.js
require("main.css");
require("logo.png");

the above requirements are based on the premise that index.js cannot be changed manually and new entry files are not generated. Can this function be dynamically implemented in the compilation of webpack , such as using plugin ? Solution, thank you!


there is a CopyWebPlugin


you can use node, to read the index.js file, and then inject the code of the require file at the top to generate a temporary entry file;
then change the entry value of webpack to start compilation;
the temporary entry file is cleared at the end of compilation


https://juejin.im/post/5b4609. Magi webpack detailed configuration

MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1e9c179-465ef.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1e9c179-465ef.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?