How can I inject a build number with webpack?

webpack

Solution

You can use the DefinePlugin that will make your build info available inlined with your code:

Config

new webpack.DefinePlugin({
   __VERSION__: JSON.stringify('12345')
})

App code

console.log(__VERSION__);

Problem

I'd like to inject a build number and version information to my project as it's built with webpack. For example, so that my code can do something like: ``` var buildInfo = require("build-info"); ``` What would be the best way to generate that `build-info` module at build time?

Original source