search

Home  >  Q&A  >  body text

javascript - How does webpack hang the hash value of this build globally for use by js code?

When I use webpack to build, I want to save the hash value in a global variable so that the js of other modules can be called. I tried configuring it. Only putting it in the file name, such as output: 'a[hash].js', will have the effect. But this is not saved in the global variable and the js in the project cannot be called. I tried putting it in new webpack.DefinePlugin but I couldn’t get the hash value. Please give me some advice.

为情所困为情所困2791 days ago559

reply all(1)I'll reply

  • 为情所困

    为情所困2017-05-19 10:43:55

    I just looked at the documentation and source code, can you provide me with an idea

    You want to get the [name].[hash].bundle.js set in output.filename.

    The following substitutions are available in template strings (via
    webpack's internal TemplatedPathPlugin):

    You can try TemplatedPathPlugin or extend TemplatedPathPlugin.

    reply
    0
  • Cancelreply