From 458f524cb05710e3001e3d384b991a5920d91327 Mon Sep 17 00:00:00 2001 From: Valentin Palkovic Date: Fri, 13 Oct 2023 11:46:43 +0200 Subject: [PATCH] Angular: Add source-map option to builder --- .../frameworks/angular/src/builders/build-storybook/index.ts | 4 ++++ .../angular/src/builders/build-storybook/schema.json | 5 +++++ .../frameworks/angular/src/builders/start-storybook/index.ts | 4 ++++ .../angular/src/builders/start-storybook/schema.json | 5 +++++ .../angular/src/builders/utils/standalone-options.ts | 2 ++ 5 files changed, 20 insertions(+) diff --git a/code/frameworks/angular/src/builders/build-storybook/index.ts b/code/frameworks/angular/src/builders/build-storybook/index.ts index 2c72b4d46962..9bbd4b53c3e1 100644 --- a/code/frameworks/angular/src/builders/build-storybook/index.ts +++ b/code/frameworks/angular/src/builders/build-storybook/index.ts @@ -21,6 +21,7 @@ import { addToGlobalContext } from '@storybook/telemetry'; import { buildStaticStandalone, withTelemetry } from '@storybook/core-server'; import { AssetPattern, + SourceMapUnion, StyleElement, } from '@angular-devkit/build-angular/src/builders/browser/schema'; import { StandaloneOptions } from '../utils/standalone-options'; @@ -39,6 +40,7 @@ export type StorybookBuilderOptions = JsonObject & { styles?: StyleElement[]; stylePreprocessorOptions?: StylePreprocessorOptions; assets?: AssetPattern[]; + sourceMap?: SourceMapUnion; } & Pick< // makes sure the option exists CLIOptions, @@ -92,6 +94,7 @@ const commandBuilder: BuilderHandlerFn = ( disableTelemetry, assets, previewUrl, + sourceMap = false, } = options; const standaloneOptions: StandaloneBuildOptions = { @@ -109,6 +112,7 @@ const commandBuilder: BuilderHandlerFn = ( ...(stylePreprocessorOptions ? { stylePreprocessorOptions } : {}), ...(styles ? { styles } : {}), ...(assets ? { assets } : {}), + sourceMap, }, tsConfig, webpackStatsJson, diff --git a/code/frameworks/angular/src/builders/build-storybook/schema.json b/code/frameworks/angular/src/builders/build-storybook/schema.json index 958e6ea7cc1f..594038eeecca 100644 --- a/code/frameworks/angular/src/builders/build-storybook/schema.json +++ b/code/frameworks/angular/src/builders/build-storybook/schema.json @@ -101,6 +101,11 @@ "items": { "$ref": "#/definitions/assetPattern" } + }, + "sourceMap": { + "type": ["boolean", "object"], + "description": "Configure sourcemaps. See: https://angular.io/guide/workspace-config#source-map-configuration", + "default": false } }, "additionalProperties": false, diff --git a/code/frameworks/angular/src/builders/start-storybook/index.ts b/code/frameworks/angular/src/builders/start-storybook/index.ts index b9fabda386f7..df9f9add5843 100644 --- a/code/frameworks/angular/src/builders/start-storybook/index.ts +++ b/code/frameworks/angular/src/builders/start-storybook/index.ts @@ -19,6 +19,7 @@ import { addToGlobalContext } from '@storybook/telemetry'; import { buildDevStandalone, withTelemetry } from '@storybook/core-server'; import { AssetPattern, + SourceMapUnion, StyleElement, } from '@angular-devkit/build-angular/src/builders/browser/schema'; import { StandaloneOptions } from '../utils/standalone-options'; @@ -36,6 +37,7 @@ export type StorybookBuilderOptions = JsonObject & { styles?: StyleElement[]; stylePreprocessorOptions?: StylePreprocessorOptions; assets?: AssetPattern[]; + sourceMap?: SourceMapUnion; } & Pick< // makes sure the option exists CLIOptions, @@ -111,6 +113,7 @@ const commandBuilder: BuilderHandlerFn = (options, cont loglevel, webpackStatsJson, previewUrl, + sourceMap = false, } = options; const standaloneOptions: StandaloneOptions = { @@ -134,6 +137,7 @@ const commandBuilder: BuilderHandlerFn = (options, cont ...(stylePreprocessorOptions ? { stylePreprocessorOptions } : {}), ...(styles ? { styles } : {}), ...(assets ? { assets } : {}), + sourceMap, }, tsConfig, initialPath, diff --git a/code/frameworks/angular/src/builders/start-storybook/schema.json b/code/frameworks/angular/src/builders/start-storybook/schema.json index d44d9c9f4f14..3716f31a9909 100644 --- a/code/frameworks/angular/src/builders/start-storybook/schema.json +++ b/code/frameworks/angular/src/builders/start-storybook/schema.json @@ -142,6 +142,11 @@ "type": "string", "description": "Controls level of logging during build. Can be one of: [silly, verbose, info (default), warn, error, silent].", "pattern": "(silly|verbose|info|warn|silent)" + }, + "sourceMap": { + "type": ["boolean", "object"], + "description": "Configure sourcemaps. See: https://angular.io/guide/workspace-config#source-map-configuration", + "default": false } }, "additionalProperties": false, diff --git a/code/frameworks/angular/src/builders/utils/standalone-options.ts b/code/frameworks/angular/src/builders/utils/standalone-options.ts index b77e82b372ba..ef73d78f01b5 100644 --- a/code/frameworks/angular/src/builders/utils/standalone-options.ts +++ b/code/frameworks/angular/src/builders/utils/standalone-options.ts @@ -1,6 +1,7 @@ import { BuilderContext } from '@angular-devkit/architect'; import { AssetPattern, + SourceMapUnion, StyleElement, StylePreprocessorOptions, } from '@angular-devkit/build-angular/src/builders/browser/schema'; @@ -16,6 +17,7 @@ export type StandaloneOptions = CLIOptions & styles?: StyleElement[]; stylePreprocessorOptions?: StylePreprocessorOptions; assets?: AssetPattern[]; + sourceMap?: SourceMapUnion; }; angularBuilderContext?: BuilderContext | null; tsConfig?: string;