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

Support watching feature

Open guanghechen opened this issue 4 years ago • 6 comments

  • Pass additional filePath info into transform func
  • Add watchStart feature, trigger recopy when files changed

guanghechen avatar Apr 27 '20 12:04 guanghechen

Codecov Report

Merging #42 into master will not change coverage. The diff coverage is 100.00%.

Impacted file tree graph

@@            Coverage Diff            @@
##            master       #42   +/-   ##
=========================================
  Coverage   100.00%   100.00%           
=========================================
  Files            1         1           
  Lines           50        75   +25     
  Branches        17        21    +4     
=========================================
+ Hits            50        75   +25     
Impacted Files Coverage Δ
src/index.js 100.00% <100.00%> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more Δ = absolute <relative> (impact), ø = not affected, ? = missing data Powered by Codecov. Last update 1fa1c25...7c258e3. Read the comment docs.

codecov[bot] avatar Apr 27 '20 12:04 codecov[bot]

Any plans to merge this in @vladshcherbin ?

DominicTobias-b1 avatar Sep 21 '20 10:09 DominicTobias-b1

I think maybe you can use @guanghechen/rollup-plugin-copy as a temporary alternative.

guanghechen avatar Oct 04 '20 15:10 guanghechen

@guanghechen Thanks for adding watch mode support. I tried to use your fork to copy some files from the build output directory to another location but it results in an infinite loop of builds. Somehow your fork seems to update the files in the source location and then rollup restarts the build process or something.

My configuration looks like this:

    copy({
      targets: [
        { src: 'build/modules/brz-button', dest: 'app/BlazorWebComponents/wwwroot/js/web-components/brz' },
        { src: 'build/property-*.js*', dest: 'app/BlazorWebComponents/wwwroot/js/web-components' }
      ],
      verbose: true,
      copyOnce: true // <- thought this could fix the inifnite loop but to no avail
    })

Do you have an idea what could cause this?

ViRuSTriNiTy avatar Aug 27 '21 10:08 ViRuSTriNiTy

Ok, found it.

Your plugin calls addWatchFile to instruct rollup to watch for changes ... in the build output directory in my case 🤦‍♀️. Obviously this does not make sense as the fresh build output is then immendiately picked up as changed and another build step is triggered.

Fortunately rollup provides an option to exclude certain files from watch. I extended my configuration with

  watch: {
    exclude: 'build/**'
  }

and now it works perfectly.

When I think about it now, it seems that I don't need the changes in your fork as I'm simply copying the build output file and these files don't need watching as the copy plugin would be triggered anyway when rollup initiates the build.

ViRuSTriNiTy avatar Aug 27 '21 10:08 ViRuSTriNiTy

Installed the fork and this works for me! Thanks! 👍

mindplay-dk avatar Aug 27 '21 11:08 mindplay-dk