diff --git a/README.md b/README.md
index 32505d8b..c77c649b 100644
--- a/README.md
+++ b/README.md
@@ -60,7 +60,7 @@ Also, check the [example](example) directory.
| Option | Type | Required | Description |
| ------------------ | ----------------------------------------------------------------------------------- | -------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
-| include | `string`/`array` | required | One or more paths that Sentry CLI should scan recursively for sources. It will upload all `.map` files and match associated `.js` files. |
+| include | `string`/`array`/`object` | required | One or more paths that Sentry CLI should scan recursively for sources. It will upload all `.map` files and match associated `.js` files. Can be given as an object with path-specific options. See [table below](#include) for details. |
| org | `string` | optional | The slug of the Sentry organization associated with the app. |
| project | `string` | optional | The slug of the Sentry project associated with the app. |
| authToken | `string` | optional | The authentication token to use for all communication with Sentry. Can be obtained from https://sentry.io/settings/account/api/auth-tokens/. Required scopes: `project:releases` (and `org:read` if `setCommits` option is used). |
@@ -89,6 +89,21 @@ Also, check the [example](example) directory.
| setCommits | `Object` | optional | Adds commits to Sentry. See [table below](#setCommits) for details. |
| deploy | `Object` | optional | Creates a new release deployment in Sentry. See [table below](#deploy) for details. |
+#### options.include:
+
+| Option | Type | Required | Description |
+| ------------------ | ---------------- | -------- | ---------------------------------------------- |
+| paths | `array` | required | One or more paths to scan for files to upload. |
+| ignoreFile | `string` | optional | See above. |
+| ignore | `string`/`array` | optional | See above. |
+| ext | `array` | optional | See above. |
+| urlPrefix | `string` | optional | See above. |
+| urlSuffix | `string` | optional | See above. |
+| stripPrefix | `array` | optional | See above. |
+| stripCommonPrefix | `boolean` | optional | See above. |
+| sourceMapReference | `boolean` | optional | See above. |
+| rewrite | `boolean` | optional | See above. |
+
#### options.setCommits:
| Option | Type | Required | Description |
diff --git a/src/__tests__/index.spec.js b/src/__tests__/index.spec.js
index e78c61d6..6e4fbc8a 100644
--- a/src/__tests__/index.spec.js
+++ b/src/__tests__/index.spec.js
@@ -67,6 +67,26 @@ describe('constructor', () => {
expect(sentryCliPlugin.options.include).toEqual(['foo']);
expect(sentryCliPlugin.options.ignore).toEqual(['bar']);
});
+
+ test('keeps object `ignore` option', () => {
+ const sentryCliPlugin = new SentryCliPlugin({
+ include: { paths: ['foo'], urlPrefix: '~/bar/' },
+ });
+ expect(sentryCliPlugin.options.include).toEqual({
+ paths: ['foo'],
+ urlPrefix: '~/bar/',
+ });
+ });
+
+ test('sanitizes `ignore` array option in object `ignore` option', () => {
+ const sentryCliPlugin = new SentryCliPlugin({
+ include: { paths: ['foo'], ignore: 'bar' },
+ });
+ expect(sentryCliPlugin.options.include).toEqual({
+ paths: ['foo'],
+ ignore: ['bar'],
+ });
+ });
});
describe('CLI configuration', () => {
diff --git a/src/index.js b/src/index.js
index 9cfeedd9..8ea8312d 100644
--- a/src/index.js
+++ b/src/index.js
@@ -51,13 +51,18 @@ function getLoaderName(entry) {
}
/**
- * Ensures that the passed value is in an array or an array itself.
+ * Wraps the given value in an array if it is not already an array itself.
+ * Ignores `undefined` and `null`, returning them as is.
*
- * @param {any} value Either an array or a value that should be wrapped
- * @returns {array} The array
+ * @param {any} value Either an array or a value that should be wrapped in an array
+ * @returns {array} The resulting array, or the original value if it's null/undefined
*/
function toArray(value) {
- return !value || Array.isArray(value) ? value : [value];
+ if (Array.isArray(value) || value === null || value === undefined) {
+ return value;
+ }
+
+ return [value];
}
/** Backwards compatible version of `compiler.plugin.afterEmit.tapAsync()`. */
@@ -78,7 +83,16 @@ class SentryCliPlugin {
this.options = Object.assign({}, defaults, options);
- if (options.include) this.options.include = toArray(options.include);
+ // the webpack plugin has looser type requirements than `@sentry/cli` -
+ // ensure `include` and `ignore` options are in the right format
+ if (options.include) {
+ if (typeof options.include === 'string') {
+ this.options.include = toArray(options.include);
+ }
+ if (typeof options.include === 'object') {
+ this.options.include.ignore = toArray(options.include.ignore);
+ }
+ }
if (options.ignore) this.options.ignore = toArray(options.ignore);
this.cli = this.getSentryCli();