mzgoddard / hard-source-webpack-plugin

https://www.npmjs.com/package/hard-source-webpack-plugin
ISC License
2.71k stars 160 forks source link

hard-source-webpack-plugin config for define-plugin #531

Closed komagic closed 4 years ago

komagic commented 4 years ago

Expected Behavior

Please describe what should happen Without hard-source everything works fine.

I set two scripts in package.json, npm run start:daily( cross-env NODE_ENV=daily) and npm run start:test( cross-env NODE_ENV=test),i use define- plugin define 'process.env.NODE_ENV'=process.env.NODE_ENV(daily and test), but i found that when i run start:daily with hard-source-webpack-plugin, then secondly, I change to npm run start:test, the app still in daily environment ? so what should I do make it correctly?

Actual Behavior

the app still in daily environment

Describe what actually happens

Is an error being thrown?

none

Include a stack trace if an error is occuring

Steps to Reproduce

  • Steps to create a minimal reproduction or a link to a repository containing the same
  • Any other information you find helpful reproducing an issue

Operating System, Node, and NPM dependency versions

"hard-source-webpack-plugin": "^0.13.1"

Mac OS 10.11.6
Node 9.2.0
iajun commented 4 years ago
    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