How to pass the build hash as an environment variable in webpack?

前端 未结 1 350
故里飘歌
故里飘歌 2021-01-11 10:12

I\'ve got an internal application that\'s built using webpack that gets deployed frequently. In order to make bug reporting easier, I want to include an environment variable

1条回答
  •  离开以前
    2021-01-11 10:50

    https://github.com/webpack/docs/wiki/list-of-plugins#extendedapiplugin

    ExtendedAPIPlugin

    new webpack.ExtendedAPIPlugin()

    Adds useful free vars to the bundle.

    __webpack_hash__ The hash of the compilation available as free var.

    This can't be used in the DefinePlugin() but it creates a global __webpack_hash__ variable that can be accessed from anywhere inside your bundle.

    var hash = __webpack_hash__;
    

    0 讨论(0)
提交回复
热议问题