hard-source-webpack-plugin icon indicating copy to clipboard operation
hard-source-webpack-plugin copied to clipboard

environmentHash is not detecting changes to yarn.lock and not invalidating cache

Open IAMtheIAM opened this issue 8 years ago • 2 comments

My config

      new HardSourceWebpackPlugin({
         cacheDirectory : isDevServer
            ? Helpers.root('./.cache/hard-source/dev/[confighash]')
            : isDebug
               ? Helpers.root('./.cache/hard-source/debug/[confighash]')
               : Helpers.root('./.cache/hard-source/prod/[confighash]'),
         recordsPath    : isDevServer
            ? Helpers.root('./.cache/hard-source/dev/[confighash]/records.json')
            : isDebug
               ? Helpers.root('./.cache/hard-source/debug/[confighash]/records.json')
               : Helpers.root('./.cache/hard-source/prod/[confighash]/records.json'),
         configHash     : require('node-object-hash')({ sort: false }).hash,
         environmentHash: {
            directories: ['node_modules'],
            files      : ['npm-shrinkwrap.json', 'yarn.lock'],
            root       : process.cwd()
         }
      }),

Anytime yarn.lock or npm-shrinkwrap.json changes, it should invalidate the cache. However, it simply is not doing that. Therefore, any time I add a new package via npm install newpackage -S or yarn add newpackage the cache is immediately invalid and the build breaks. I have to manually delete .cache folder almost every day.

IAMtheIAM avatar Oct 19 '17 16:10 IAMtheIAM

Anyone there?

IAMtheIAM avatar Oct 26 '17 18:10 IAMtheIAM

Probably too late to the party, but my first guess would be that root: process.cwd() is probably pointing at the wrong directory.

Assuming your config file lives in the root, something like root: __dirname may produce the result you're expecting. __dirname always points to the directory containing the file.

markfinger avatar Jan 21 '18 21:01 markfinger