diff --git a/README.md b/README.md index e264ded5..b0581381 100644 --- a/README.md +++ b/README.md @@ -296,6 +296,8 @@ Default: `[]` Globs to ignore files. +May also contain Minimatch setting objects (e.g. `{dot: true, matchBase: true}`). + **webpack.config.js** ```js @@ -534,6 +536,8 @@ module.exports = { Array of globs to ignore (applied to `from`). +Like per-pattern ignores, may also contain Minimatch setting objects. + **webpack.config.js** ```js diff --git a/src/index.js b/src/index.js index f72b4804..0f080c9b 100644 --- a/src/index.js +++ b/src/index.js @@ -3,14 +3,16 @@ import path from 'path'; import validateOptions from 'schema-utils'; import log from 'webpack-log'; -import schema from './options.json'; +import patternsSchema from './patterns.json'; +import optionsSchema from './options.json'; import preProcessPattern from './preProcessPattern'; import processPattern from './processPattern'; import postProcessPattern from './postProcessPattern'; class CopyPlugin { constructor(patterns = [], options = {}) { - validateOptions(schema, patterns, this.constructor.name); + validateOptions(patternsSchema, patterns, this.constructor.name); + validateOptions(optionsSchema, options, this.constructor.name); this.patterns = patterns; this.options = options; diff --git a/src/options.json b/src/options.json index 90c465d6..62381e70 100644 --- a/src/options.json +++ b/src/options.json @@ -1,90 +1,33 @@ { - "definitions": { - "ObjectPattern": { - "type": "object", - "properties": { - "from": { - "anyOf": [ - { - "type": "string", - "minLength": 1 - }, - { - "type": "object" - } - ] - }, - "to": { - "type": "string" - }, - "context": { - "type": "string" - }, - "toType": { - "enum": ["dir", "file", "template"] - }, - "test": { - "anyOf": [ - { - "type": "string" - }, - { - "instanceof": "RegExp" - } - ] - }, - "force": { - "type": "boolean" - }, - "ignore": { - "type": "array", - "items": { - "anyOf": [ - { - "type": "string" - }, - { - "type": "object" - } - ] + "type": "object", + "additionalProperties": false, + "properties": { + "logLevel": { + "description": "Level of messages that the module will log", + "enum": ["trace", "debug", "info", "warn", "error", "silent"] + }, + "ignore": { + "description": "Array of globs to ignore (applied to `from`)", + "type": "array", + "items": { + "anyOf": [ + { + "type": "string" + }, + { + "type": "object" } - }, - "flatten": { - "type": "boolean" - }, - "cache": { - "anyOf": [ - { - "type": "boolean" - }, - { - "type": "object" - } - ] - }, - "transform": { - "instanceof": "Function" - }, - "transformPath": { - "instanceof": "Function" - } - }, - "required": ["from"] + ] + } }, - "StringPattern": { - "type": "string", - "minLength": 1 + "context": { + "description": "A path that determines how to interpret the `from` path, shared for all patterns", + "type": "string" + }, + "copyUnmodified": { + "description": "Copies files, regardless of modification, when using watchers", + "type": "boolean" } }, - "type": "array", - "items": { - "anyOf": [ - { - "$ref": "#/definitions/StringPattern" - }, - { - "$ref": "#/definitions/ObjectPattern" - } - ] - } + "title": "Options" } diff --git a/src/patterns.json b/src/patterns.json new file mode 100644 index 00000000..90c465d6 --- /dev/null +++ b/src/patterns.json @@ -0,0 +1,90 @@ +{ + "definitions": { + "ObjectPattern": { + "type": "object", + "properties": { + "from": { + "anyOf": [ + { + "type": "string", + "minLength": 1 + }, + { + "type": "object" + } + ] + }, + "to": { + "type": "string" + }, + "context": { + "type": "string" + }, + "toType": { + "enum": ["dir", "file", "template"] + }, + "test": { + "anyOf": [ + { + "type": "string" + }, + { + "instanceof": "RegExp" + } + ] + }, + "force": { + "type": "boolean" + }, + "ignore": { + "type": "array", + "items": { + "anyOf": [ + { + "type": "string" + }, + { + "type": "object" + } + ] + } + }, + "flatten": { + "type": "boolean" + }, + "cache": { + "anyOf": [ + { + "type": "boolean" + }, + { + "type": "object" + } + ] + }, + "transform": { + "instanceof": "Function" + }, + "transformPath": { + "instanceof": "Function" + } + }, + "required": ["from"] + }, + "StringPattern": { + "type": "string", + "minLength": 1 + } + }, + "type": "array", + "items": { + "anyOf": [ + { + "$ref": "#/definitions/StringPattern" + }, + { + "$ref": "#/definitions/ObjectPattern" + } + ] + } +}