Skip to content

Commit

Permalink
🤖 Merge PR DefinitelyTyped#47184 feat(copy-webpack-plugin): assets fi…
Browse files Browse the repository at this point in the history
…ltering and v6.2 by @peterblazejewicz

- remove /// node types  reference
- filter option
- minor version bump

webpack-contrib/copy-webpack-plugin@v6.1.1...v6.2.0

Thanks!
  • Loading branch information
peterblazejewicz authored Nov 4, 2020
1 parent 0035593 commit 51599b9
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 4 deletions.
18 changes: 18 additions & 0 deletions types/copy-webpack-plugin/copy-webpack-plugin-tests.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
import { Configuration } from 'webpack';
import CopyPlugin = require('copy-webpack-plugin');
import path = require('path');
import fs = require('fs');

const _: Configuration = {
plugins: [
// basic
new CopyPlugin(),
new CopyPlugin({
patterns: [
{ from: 'source', to: 'dest' },
Expand Down Expand Up @@ -65,6 +67,22 @@ const _: Configuration = {
},
],
}),
// filter
new CopyPlugin({
patterns: [
{
from: path.resolve(__dirname, 'file.txt'),
filter: (resourcePath) => {
const data = fs.readFileSync(resourcePath);
const content = data.toString();
if (content === 'my-custom-content') {
return false;
}
return true;
},
},
],
}),
// to
new CopyPlugin({
patterns: [
Expand Down
10 changes: 6 additions & 4 deletions types/copy-webpack-plugin/index.d.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,9 @@
// Type definitions for copy-webpack-plugin 6.0
// Type definitions for copy-webpack-plugin 6.2
// Project: https://github.com/webpack-contrib/copy-webpack-plugin
// Definitions by: flying-sheep <https://github.com/flying-sheep>
// avin-kavish <https://github.com/avin-kavish>
// Piotr Błażejewicz <https://github.com/peterblazejewicz>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped

/// <reference types="node"/>

import { Plugin } from 'webpack';

interface ObjectPattern {
Expand Down Expand Up @@ -39,6 +36,11 @@ interface ObjectPattern {
*/
globOptions?: object;

/**
* Allows to filter copied assets.
*/
filter?: (resourcePath: string) => boolean;

/**
* How to interpret `to`. default: undefined
* `file` - if 'to' has extension or 'from' is file.
Expand Down

0 comments on commit 51599b9

Please sign in to comment.