-
-
Notifications
You must be signed in to change notification settings - Fork 9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Feature request: Async configuration via webpack.config.js #2697
Labels
Comments
Yeah. With webpack 2 you get exports default function(options) {
return {
// ...
devtool: options.dev ? "cheap-module-eval-source-map" : "hidden-source-map"
};
} Expanding to exports default function(options, cb) {
cb(null, {
// ...
devtool: options.dev ? "cheap-module-eval-source-map" : "hidden-source-map"
});
} would seem like a good move to me. |
You can return a Promise with webpack@2 |
It also works with Webpack 1. It doesn't work yet with Webpack 1's development server, however. See webpack/webpack-dev-server#698 for that. |
For reference, for anyone stumbling here, returning a promise like what @sokra said looks something like this: const configPromise = new Promise(function(resolve, reject) {
// ... do async stuff ...
// then at some point call `resolve()` with the config object:
resolve({
entry: { /* ... */ },
resolve: { /* ... */ },
// etc
})
})
module.exports = configPromise |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
The text was updated successfully, but these errors were encountered: