Skip to content

Commit

Permalink
Merge pull request #23489 from storybookjs/valentin/make-enable-prod-…
Browse files Browse the repository at this point in the history
…mode-in-angular-optional

Angular: Make enableProdMode optional
(cherry picked from commit 10e38b5)
  • Loading branch information
valentinpalkovic authored and storybook-bot committed Jul 24, 2023
1 parent 697a8dc commit 4e19b56
Show file tree
Hide file tree
Showing 6 changed files with 19 additions and 1 deletion.
3 changes: 3 additions & 0 deletions code/frameworks/angular/src/builders/build-storybook/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ export type StorybookBuilderOptions = JsonObject & {
docs: boolean;
compodoc: boolean;
compodocArgs: string[];
enableProdMode?: boolean;
styles?: StyleElement[];
stylePreprocessorOptions?: StylePreprocessorOptions;
assets?: AssetPattern[];
Expand Down Expand Up @@ -78,6 +79,7 @@ const commandBuilder: BuilderHandlerFn<StorybookBuilderOptions> = (
loglevel,
outputDir,
quiet,
enableProdMode = true,
webpackStatsJson,
disableTelemetry,
assets,
Expand All @@ -90,6 +92,7 @@ const commandBuilder: BuilderHandlerFn<StorybookBuilderOptions> = (
loglevel,
outputDir,
quiet,
enableProdMode,
disableTelemetry,
angularBrowserTarget: browserTarget,
angularBuilderContext: context,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,11 @@
"description": "Controls level of logging during build. Can be one of: [silly, verbose, info (default), warn, error, silent].",
"pattern": "(silly|verbose|info|warn|silent)"
},
"enableProdMode": {
"type": "boolean",
"description": "Disable Angular's development mode, which turns off assertions and other checks within the framework.",
"default": true
},
"quiet": {
"type": "boolean",
"description": "Suppress verbose build output.",
Expand Down
3 changes: 3 additions & 0 deletions code/frameworks/angular/src/builders/start-storybook/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ export type StorybookBuilderOptions = JsonObject & {
tsConfig?: string;
compodoc: boolean;
compodocArgs: string[];
enableProdMode?: boolean;
styles?: StyleElement[];
stylePreprocessorOptions?: StylePreprocessorOptions;
assets?: AssetPattern[];
Expand Down Expand Up @@ -93,6 +94,7 @@ const commandBuilder: BuilderHandlerFn<StorybookBuilderOptions> = (options, cont
https,
port,
quiet,
enableProdMode = false,
smokeTest,
sslCa,
sslCert,
Expand All @@ -112,6 +114,7 @@ const commandBuilder: BuilderHandlerFn<StorybookBuilderOptions> = (options, cont
https,
port,
quiet,
enableProdMode,
smokeTest,
sslCa,
sslCert,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,11 @@
"description": "Suppress verbose build output.",
"default": false
},
"enableProdMode": {
"type": "boolean",
"description": "Disable Angular's development mode, which turns off assertions and other checks within the framework.",
"default": false
},
"docs": {
"type": "boolean",
"description": "Starts Storybook in documentation mode. Learn more about it : https://storybook.js.org/docs/react/writing-docs/build-documentation#preview-storybooks-documentation.",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ export type StandaloneOptions = CLIOptions &
LoadOptions &
BuilderOptions & {
mode?: 'static' | 'dev';
enableProdMode: boolean;
angularBrowserTarget?: string | null;
angularBuilderOptions?: Record<string, any> & {
styles?: StyleElement[];
Expand Down
3 changes: 2 additions & 1 deletion code/frameworks/angular/src/preset.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { dirname, join } from 'path';
import { PresetProperty } from '@storybook/types';
import { StorybookConfig } from './types';
import { StandaloneOptions } from './builders/utils/standalone-options';

const wrapForPnP = (input: string) => dirname(require.resolve(join(input, 'package.json')));

Expand All @@ -16,7 +17,7 @@ export const previewAnnotations: StorybookConfig['previewAnnotations'] = (
) => {
const annotations = [...entries, require.resolve('./client/config')];

if (options.configType === 'PRODUCTION') {
if ((options as any as StandaloneOptions).enableProdMode) {
annotations.unshift(require.resolve('./client/preview-prod'));
}

Expand Down

0 comments on commit 4e19b56

Please sign in to comment.