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

I wonder if it is possible not to copy a file when it conforms to a set of regular expressions

Open SuGod opened this issue 5 years ago • 7 comments

copy({
  targets: [{ src: 'src/*', exclude: ['*.md', 'demo'], dest: 'dist' }],
})

SuGod avatar May 23 '20 17:05 SuGod

not using regular expressions, but using glob syntax from main readme

truesilver92 avatar May 29 '20 20:05 truesilver92

the negate pattern doesn't seem to work. it just copies all files.

copy({ targets: [ { src: ['!**/*.scss', '!**/*.svg', 'src/themes/**/*'], dest: 'lib' }, ], flatten: false, }),

pancake-boy avatar Jan 21 '21 03:01 pancake-boy

@pancake-boy I believe it's a question of order. the negation patterns exclude previously matched files. Try putting the 'src/themes/**/*' first in the array.

ivanjonas avatar Feb 17 '21 16:02 ivanjonas

@pancake-boy I believe it's a question of order. the negation patterns exclude previously matched files. Try putting the 'src/themes/**/*' first in the array.

I can't get the negated patterns to work 100% either. Tried a bunch of different ways

copy({ targets: [{ src: ['public/*', '!public/tiles'], dest: OUT_DIR }] }), this works, will skip tiles directory

copy({ targets: [{ src: ['public/*', '!*.map', '!public/tiles'], dest: OUT_DIR }] }), this doesn't skip .map files but does skip tiles directory

copy({ targets: [{ src: ['public/*', '!**/*.map', '!public/tiles'], dest: OUT_DIR }] }), this is the example from the Readme and it does not skip .map files

copy({ targets: [{ src: ['public/*', '!public/**/*.map', '!public/tiles'], dest: OUT_DIR }] }), this also does not skip .map files

brgrz avatar Apr 15 '21 16:04 brgrz

Also negated pattern with template literals don't work either copy({ targets: [{ src: [`${PUBLIC_ASSETS_DIR}/*`, `!${PUBLIC_ASSETS_DIR}}/tiles`], dest: OUT_DIR }] })

brgrz avatar Apr 15 '21 16:04 brgrz

negated patterns not work + 1 {src: ['src/data', '!src/data/geojson'], dest: 'dist'}

Junior2Ran avatar Nov 19 '21 02:11 Junior2Ran

To use negated patterns, I needed to specify the expandDirectories and onlyFiles options to true.

copy({
    targets: [
      {
        src: ['src/', '!src/**/*.test.ts'],
        dest: 'dist/browser/src/',
        expandDirectories: true,
        onlyFiles: true,
      },
    ],
    flatten: false,
  });

These options are intentionally being set to false here. Perhaps there is a good reason for these defaults? If so, maybe just adjusting this README.md example could be enough,

samisayegh avatar Nov 29 '21 21:11 samisayegh