How can I inject a build number with webpack?

后端 未结 7 972
野的像风
野的像风 2021-01-30 10:38

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 bui         


        
7条回答
  •  终归单人心
    2021-01-30 10:52

    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__);
    

提交回复
热议问题