trivago / parallel-webpack

Builds multi-config webpack projects in parallel
BSD 3-Clause "New" or "Revised" License
1.48k stars 96 forks source link

Could you support new feature to allow us pass the webpack configuration object directly? #104

Open tianyingchun opened 4 years ago

tianyingchun commented 4 years ago

Could you support new feature to allow us pass the webpack configuration object directly?

for now

var run = require('parallel-webpack').run,
    configPath = require.resolve('./webpack.config.js');

run(configPath, {
    watch: false,
    maxRetries: 1,
    stats: true, // defaults to false
    maxConcurrentWorkers: 2 // use 2 workers
});

new feature is.

run({ .... webpack configuration here. }, {
    watch: false,
    maxRetries: 1,
    stats: true, // defaults to false
    maxConcurrentWorkers: 2 // use 2 workers
});
jlurena commented 3 years ago

@tianyingchun you can pass in a file that returns a callback function.

some-file.js
module.exports = () => { /** webpack configuration object /* } ;

then call it with

var run = require('parallel-webpack').run,
    configPath = require.resolve('some-file.js');

run(configPath, {
    watch: false,
    maxRetries: 1,
    stats: true, // defaults to false
    maxConcurrentWorkers: 2 // use 2 workers
});