1.8.5: “Error: Path variable [hash] not implemented in this context”

With 1.8.5, I started to see the following error when running my production webpack configuration:

/tmp/build_4e438b7bfaf8aa2695db290c4d71726e/node_modules/webpack/lib/TemplatedPathPlugin.js:50
            if (!allowEmpty) throw new Error("Path variable " + match + " not implement
                                   ^
Error: Path variable [hash] not implemented in this context: https://dnmx4o8i2d15m.cloudfront.net/assets/[hash]/
    at /tmp/build_4e438b7bfaf8aa2695db290c4d71726e/node_modules/webpack/lib/TemplatedPathPlugin.js:50:27
    at /tmp/build_4e438b7bfaf8aa2695db290c4d71726e/node_modules/webpack/lib/TemplatedPathPlugin.js:40:23
    at String.replace (native)
    at Tapable.replacePathVariables (/tmp/build_4e438b7bfaf8aa2695db290c4d71726e/node_modules/webpack/lib/TemplatedPathPlugin.js:66:4)
    at Tapable.applyPlugins [as applyPluginsWaterfall] (/tmp/build_4e438b7bfaf8aa2695db290c4d71726e/node_modules/webpack/node_modules/tapable/lib/Tapable.js:37:47)
    at Tapable.MainTemplate.getPublicPath (/tmp/build_4e438b7bfaf8aa2695db290c4d71726e/node_modules/webpack/lib/MainTemplate.js:148:14)
    at Stats.toJson (/tmp/build_4e438b7bfaf8aa2695db290c4d71726e/node_modules/webpack/lib/Stats.js:113:50)
    at Tapable.<anonymous> (/tmp/build_4e438b7bfaf8aa2695db290c4d71726e/webpack.config.js:71:53)
    at Tapable.applyPlugins (/tmp/build_4e438b7bfaf8aa2695db290c4d71726e/node_modules/webpack/node_modules/tapable/lib/Tapable.js:26:37)
    at Tapable.<anonymous> (/tmp/build_4e438b7bfaf8aa2695db290c4d71726e/node_modules/webpack/lib/Compiler.js:191:12)

this.compilation.renderedHash seems to be undefined here: d9509e8#diff-baf371f5446dc9bc4b41022587e05b48R114

This seems to occur with the following plugin in my config:

  plugins: [
    ...
    function() {
      // Write the stats.json file out to the output directory
      this.plugin('done', function(stats) {
        var file = path.join(__dirname, 'build/stats.json');
        fs.writeFileSync(file, JSON.stringify(stats.toJson()));
      }); 
    }
  ]

I pinned webpack to 1.8.4 to avoid this for now.

Author: Fantashit

3 thoughts on “1.8.5: “Error: Path variable [hash] not implemented in this context”

  1. Hello, was this solved? I get the same with “webpack”: “3.5.5”

    Error: Path variable [chunkhash] not implemented in this context: assets/bio_bg_blue.[chunkhash].jpg

  2. Error: Path variable [contenthash:8] not implemented in this context: styles.[contenthash:8].css
    

    webpack: “4.5.0”

Comments are closed.