Webpack replacement configuration items and compressed js, css, are not packaged! No packing! No packing!

problem description

A js tool project. has multiple directories . After deployment, the address is provided for others to call. However, some api API addresses in the project are different in different development, testing and production environments, so you want to replace them with webpack"s define plug-in after each environment is configured.
what I expect is that only wants to replace configuration items and compress js, and css, does not package .

the environmental background of the problems and what methods you have tried

during the research, only the define replacement of a single file was tried, and there was no problem. When applied to the project, it is found that entry can be generated through glob, but it will be packaged during compilation, so some Module not found, cannot continue.

related codes

/ / Please paste the code text below (do not replace the code with pictures)

//entries
var entries= function () {
 var srcDir = resolve("/src/")
 var entryFiles = glob.sync(srcDir + "**/*.js")
 var map = {};
 for (var i = 0; i < entryFiles.length; iPP) {
  var filePath = entryFiles[i];
  var filename = filePath.substring(filePath.lastIndexOf("\/") + 1, filePath.lastIndexOf("."));
  map[filename] = filePath;
 }
 console.log(map)
 return map;
}

// define
new webpack.DefinePlugin(function () {
    let obj = {}
    for (let key in config) {
        obj["envConfig." + key] = config[key]
    }
    return obj
}())

what result do you expect?

I don"t know if there is any plan to realize my expectations. I hope all experienced bosses can give me a helping hand. Thank you!

Jul.16,2021

if it's just a replacement, why write a random script with webpack, when plain text is read in and replaced and written back.


you can use idebar/Sidebar.jsx" rel=" nofollow noreferrer "> externals

Don't use webpack if you don't pack.


finally did not use webpack, webpack modular packaging, not suitable for my scenario.
various logical judgments are done by traversing the directory with nodejs.
Thank you for answering


process processing. You can use process processing tools such as gulp and grunt.
for code compression, you can use the corresponding plug-in, not packaged.

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-1eb0c44-2307.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-1eb0c44-2307.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?