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

Feature request: detect webpack.DefinePlugin usage and dirty the cache on value change

Open EdwardDrapkin opened this issue 6 years ago • 2 comments
trafficstars

We use HardSource and we love it. It's been a huge boon to our productivity, so many thanks.

One thing we run into fairly frequently is that we use the DefinePlugin in webpack to define some API keys and such, and when those change, we have to blow away the cache. It's not a huge deal, but it is a little annoying to have to blow away the entire cache instead of just the files that need to be recompiled with the new DefinePlugin'd values. Is it possible for you guys to detect usage of that plugin, then detect the files the plugin actually applies to, and dirty them in the cache?

EdwardDrapkin avatar Apr 05 '19 15:04 EdwardDrapkin

+1, this is something that can harm users

cursedcoder avatar Feb 27 '20 18:02 cursedcoder

new HardSourceWebpackPlugin({
  cacheDirectory: path.resolve(__dirname, '../.cache/hard-source/[confighash]'),
  info: {
    mode: 'none',
    level: 'error',
  },
  environmentHash: {
    root: process.cwd(),
    directories: ['config'],
    files: ['package-lock.json', 'yarn.lock'],
  },
}),

By adding my env files into environmentHash dirs, I solved it

iajun avatar Aug 31 '20 11:08 iajun