Feature request: Async configuration via webpack.config.js
Webpack version:
1.12.2
Please tell us about your environment:
Linux (OS independent problem)
Current behavior:
Configuration in webpack.config.js must define an object as module.exports.
Expected/desired behavior:
Configuration in webpack.config.js should also support async resolving of module.exports (e.g. by assigning a promise, future and/or callback to module.exports).
What is the motivation / use case for changing the behavior?
I stepped upon the same problem as described in defineplugin-from-async.
In my case I would like to include some git information (branch, last commit, current value of git-describe) as a constant into the bundled javascript code. With help of nodegit, it is relatively simple to retrieve this – but nodegit is an asynchronous node library.
While there is a work-around (by running webpack through the node API, see link above), my feeling is that allowing an async configuration webpack would simplify more advanced use-cases.
You can return a Promise with webpack@2
For reference, for anyone stumbling here, returning a promise like what @sokra said looks something like this: