From 9c2ebfe71df44bf435b6650b9c7c1580141399e7 Mon Sep 17 00:00:00 2001 From: Leon Radley Date: Tue, 8 Mar 2022 17:26:13 +0100 Subject: [PATCH] fix(storybook): add staticDir object schema (#8885) Adds schema for the more advanced storybook staticDirs config defined here. https://storybook.js.org/docs/react/configure/images-and-assets --- .../api-storybook/executors/storybook.md | 10 +++++- .../src/executors/storybook/schema.json | 32 +++++++++++++++++++ .../src/executors/storybook/storybook.impl.ts | 1 + 3 files changed, 42 insertions(+), 1 deletion(-) diff --git a/docs/generated/api-storybook/executors/storybook.md b/docs/generated/api-storybook/executors/storybook.md index 8202562f16fca..b68700a469d6d 100644 --- a/docs/generated/api-storybook/executors/storybook.md +++ b/docs/generated/api-storybook/executors/storybook.md @@ -79,12 +79,20 @@ Type: `string` SSL key to use for serving HTTPS. -### staticDir +### ~~staticDir~~ Type: `array` +**Deprecated:** This field has been renamed to staticDirs. + Directory where to load static files from, array of strings +### staticDirs + +Type: `array` + +Directory where to load static files from, array of strings or object with from, to keys + ### stylePreprocessorOptions.includePaths Type: `array` diff --git a/packages/storybook/src/executors/storybook/schema.json b/packages/storybook/src/executors/storybook/schema.json index 312389fbf6c82..359ea6dc682f8 100644 --- a/packages/storybook/src/executors/storybook/schema.json +++ b/packages/storybook/src/executors/storybook/schema.json @@ -50,8 +50,18 @@ "staticDir": { "type": "array", "description": "Directory where to load static files from, array of strings", + "default": [], "items": { "type": "string" + }, + "x-deprecated": "This field has been renamed to staticDirs." + }, + "staticDirs": { + "type": "array", + "description": "Directory where to load static files from, array of strings or object with from, to keys", + "default": [], + "items": { + "$ref": "#/definitions/staticDirPattern" } }, "projectBuildConfig": { @@ -134,6 +144,28 @@ "description": "The file to include." } ] + }, + "staticDirPattern": { + "oneOf": [ + { + "type": "object", + "properties": { + "from": { + "type": "string", + "description": "From path" + }, + "to": { + "type": "string", + "description": "To path" + } + }, + "additionalProperties": false, + "required": ["from", "to"] + }, + { + "type": "string" + } + ] } }, "required": ["uiFramework", "config"] diff --git a/packages/storybook/src/executors/storybook/storybook.impl.ts b/packages/storybook/src/executors/storybook/storybook.impl.ts index 2256087289ce5..099454f0990ed 100644 --- a/packages/storybook/src/executors/storybook/storybook.impl.ts +++ b/packages/storybook/src/executors/storybook/storybook.impl.ts @@ -16,6 +16,7 @@ export interface StorybookExecutorOptions extends CommonNxStorybookConfig { sslCert?: string; sslKey?: string; staticDir?: string[]; + staticDirs?: string[] | { from: string; to: string }[]; watch?: boolean; docsMode?: boolean; }