I'd like to define some constants that are returned from an asynchronous resource. Is there anyway to do this in Webpack?
/* webpack.config.js */
module.exports = {
...,
plugins: [
new webpack.DefinePlugin({
someVar: /* RETURN VARIABLE FROM ASYNC FUNCTION */
})
]
}
A good way to do this is to return a Promise from webpack configuration.
webpack.config.js
...
module.exports = () => {
return getYourAsyncResource().then((someVar) => {
// Resolve as webpack configuration
return {
...
plugins: [
new webpack.DefinePlugin({ someVar })
]
};
})
};
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With