let num
(new Array(num)),map((v, k) = {
let start = +new Date()
webpack(webpackConfig, () => {
console.log(`time:${+new Date() - start} ms)
})
})
num = 1
time:5232ms
num = 2
time:9212ms
time:9332ms
...
num = 30
time:40212ms
time:40342ms
...
time: 4xxxxms
曾经蜡笔没有小新2017-07-05 10:45:10
Nodejs execution is single-threaded, but your results are related to the way you write it.
The expected effect is who builds it first and returns it first, not together
You can try the following two solutions, the second of which can achieve true parallelism
1: Write each webpack task construction method in the loop to asynchronously, such as setTimeOut.
2: Start multiple node processes and execute webpack build on each process