rollup-plugin-re icon indicating copy to clipboard operation
rollup-plugin-re copied to clipboard

Option to rerun provider fonction every rebuild

Open OoDeLally opened this issue 6 years ago • 0 comments

{
  //...
  watch: {
    input: [
      // ...
      './src/fileToInject.txt',
    ],
  },
  plugins: [
    // ...
    replace({
      replaces: {
        __PLACEHOLDER__: (data) => {
          return fs.readFileSync('./src/fileToInject.txt', 'utf-8')
        },
      }
    })
  ],
}

Expected result:

Everytime I modify fileToInject.txt, I would like my bundle to be updated with the latest content.

Current result:

Currently the function is evaluated only once at the first build. When the watcher detects a change, the bundle is rebuilt, but the replace plugin reuses the last value returned by the function. Therefore my bundle is not updated.

Solution:

Provide a evaluateEveryTime or such option.

OoDeLally avatar Feb 06 '19 10:02 OoDeLally