From 9d6a9de8da098c4fcd4381770aab7ded3bf8f8fc Mon Sep 17 00:00:00 2001 From: Valentin Palkovic Date: Tue, 11 Jul 2023 15:27:23 +0200 Subject: [PATCH] Merge pull request #23404 from storybookjs/valentin/use-angular-prod-mode Angular: Enable prod mode when Storybook is built (cherry picked from commit a46cbb1cdb1553dc7fa9b17e711d1e4893861bc4) --- .../angular/src/client/preview-prod.ts | 3 +++ code/frameworks/angular/src/preset.ts | 16 ++++++++++++---- 2 files changed, 15 insertions(+), 4 deletions(-) create mode 100644 code/frameworks/angular/src/client/preview-prod.ts diff --git a/code/frameworks/angular/src/client/preview-prod.ts b/code/frameworks/angular/src/client/preview-prod.ts new file mode 100644 index 000000000000..13a257400434 --- /dev/null +++ b/code/frameworks/angular/src/client/preview-prod.ts @@ -0,0 +1,3 @@ +import { enableProdMode } from '@angular/core'; + +enableProdMode(); diff --git a/code/frameworks/angular/src/preset.ts b/code/frameworks/angular/src/preset.ts index 016e104e5a6f..76274592ddbc 100644 --- a/code/frameworks/angular/src/preset.ts +++ b/code/frameworks/angular/src/preset.ts @@ -10,10 +10,18 @@ export const addons: PresetProperty<'addons', StorybookConfig> = [ require.resolve('./server/framework-preset-angular-docs'), ]; -export const previewAnnotations: StorybookConfig['previewAnnotations'] = (entries = []) => [ - ...entries, - require.resolve('./client/config'), -]; +export const previewAnnotations: StorybookConfig['previewAnnotations'] = ( + entries = [], + options +) => { + const annotations = [...entries, require.resolve('./client/config')]; + + if (options.configType === 'PRODUCTION') { + annotations.unshift(require.resolve('./client/preview-prod')); + } + + return annotations; +}; export const core: PresetProperty<'core', StorybookConfig> = async (config, options) => { const framework = await options.presets.apply('framework');