@analogjs/storybook-angular 3.0.0-alpha.2 → 3.0.0-alpha.20
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +7 -9
- package/preset.js +1 -1
- package/src/index.d.ts +2 -2
- package/src/index.js +2 -2
- package/src/lib/build-storybook/build-storybook.d.ts +1 -1
- package/src/lib/build-storybook/build-storybook.js +6 -2
- package/src/lib/build-storybook/build-storybook.js.map +1 -1
- package/src/lib/preset.d.ts +3 -3
- package/src/lib/preset.js +116 -164
- package/src/lib/preset.js.map +1 -1
- package/src/lib/start-storybook/start-storybook.d.ts +1 -1
- package/src/lib/start-storybook/start-storybook.js +6 -2
- package/src/lib/start-storybook/start-storybook.js.map +1 -1
- package/src/lib/storybook-angular.d.ts +12 -0
- package/src/lib/testing.d.ts +5 -4
- package/src/lib/testing.js +16 -17
- package/src/lib/testing.js.map +1 -1
- package/src/lib/utils/standalone-options.d.ts +7 -7
- package/src/types.d.ts +21 -21
- package/README.md +0 -270
- package/src/index.js.map +0 -1
- package/src/lib/utils/standalone-options.js +0 -1
- package/src/lib/utils/standalone-options.js.map +0 -1
- package/src/types.js +0 -1
- package/src/types.js.map +0 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@analogjs/storybook-angular",
|
|
3
|
-
"version": "3.0.0-alpha.
|
|
3
|
+
"version": "3.0.0-alpha.20",
|
|
4
4
|
"description": "Storybook Integration for Angular & Vite",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"keywords": [
|
|
@@ -34,7 +34,7 @@
|
|
|
34
34
|
"default": "./src/lib/testing.js"
|
|
35
35
|
}
|
|
36
36
|
},
|
|
37
|
-
"main": "src/index.js",
|
|
37
|
+
"main": "./src/index.js",
|
|
38
38
|
"dependencies": {
|
|
39
39
|
"@storybook/builder-vite": "^10.0.0"
|
|
40
40
|
},
|
|
@@ -42,12 +42,12 @@
|
|
|
42
42
|
"@storybook/angular": "^10.0.0",
|
|
43
43
|
"@analogjs/vite-plugin-angular": "*",
|
|
44
44
|
"storybook": "^10.0.0",
|
|
45
|
-
"vite": "^
|
|
45
|
+
"vite": "^6.0.0 || ^7.0.0 || ^8.0.0"
|
|
46
46
|
},
|
|
47
47
|
"engines": {
|
|
48
|
-
"node": ">=
|
|
48
|
+
"node": ">=22.0.0"
|
|
49
49
|
},
|
|
50
|
-
"builders": "src/lib/builders.json",
|
|
50
|
+
"builders": "./src/lib/builders.json",
|
|
51
51
|
"ng-add": {
|
|
52
52
|
"save": "devDependencies"
|
|
53
53
|
},
|
|
@@ -65,7 +65,5 @@
|
|
|
65
65
|
"publishConfig": {
|
|
66
66
|
"access": "public",
|
|
67
67
|
"provenance": true
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
"module": "./src/index.js"
|
|
71
|
-
}
|
|
68
|
+
}
|
|
69
|
+
}
|
package/preset.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export * from './src/lib/preset.js';
|
|
1
|
+
export * from './dist/src/lib/preset.js';
|
package/src/index.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export { type AngularOptions, type Parameters as AngularParameters, type AngularRenderer, type Decorator, type IStory, type Loader, type Meta, type Preview, type StoryContext, type StoryFn, type StoryObj, applicationConfig, argsToTemplate, componentWrapperDecorator, moduleMetadata, setProjectAnnotations
|
|
2
|
-
export { type FrameworkOptions, type StorybookConfig } from
|
|
1
|
+
export { type AngularOptions, type Parameters as AngularParameters, type AngularRenderer, type Decorator, type IStory, type Loader, type Meta, type Preview, type StoryContext, type StoryFn, type StoryObj, applicationConfig, argsToTemplate, componentWrapperDecorator, moduleMetadata, setProjectAnnotations } from "@storybook/angular";
|
|
2
|
+
export { type FrameworkOptions, type StorybookConfig } from "./types";
|
package/src/index.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
import { applicationConfig, argsToTemplate, componentWrapperDecorator, moduleMetadata, setProjectAnnotations } from "@storybook/angular";
|
|
2
|
+
export { applicationConfig, argsToTemplate, componentWrapperDecorator, moduleMetadata, setProjectAnnotations };
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import BuildStorybookBuilder from
|
|
1
|
+
import BuildStorybookBuilder from "@storybook/angular/builders/build-storybook";
|
|
2
2
|
export default BuildStorybookBuilder;
|
|
@@ -1,3 +1,7 @@
|
|
|
1
|
-
import BuildStorybookBuilder from
|
|
2
|
-
|
|
1
|
+
import BuildStorybookBuilder from "@storybook/angular/builders/build-storybook";
|
|
2
|
+
//#region packages/storybook-angular/src/lib/build-storybook/build-storybook.ts
|
|
3
|
+
var build_storybook_default = BuildStorybookBuilder;
|
|
4
|
+
//#endregion
|
|
5
|
+
export { build_storybook_default as default };
|
|
6
|
+
|
|
3
7
|
//# sourceMappingURL=build-storybook.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"build-storybook.js","
|
|
1
|
+
{"version":3,"file":"build-storybook.js","names":[],"sources":["../../../../src/lib/build-storybook/build-storybook.ts"],"sourcesContent":["import BuildStorybookBuilder from '@storybook/angular/builders/build-storybook';\n\nexport default BuildStorybookBuilder;\n"],"mappings":";;AAEA,IAAA,0BAAe"}
|
package/src/lib/preset.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export declare const previewAnnotations: (entries:
|
|
1
|
+
export declare const previewAnnotations: (entries: string[] | undefined, options: any) => Promise<string[]>;
|
|
2
2
|
export declare const core: (config: any, options: any) => Promise<any>;
|
|
3
|
-
export declare const viteFinal: (config: any, options: any) => Promise<
|
|
4
|
-
export { addons } from
|
|
3
|
+
export declare const viteFinal: (config: any, options: any) => Promise<any>;
|
|
4
|
+
export { addons } from "@storybook/angular/preset";
|
package/src/lib/preset.js
CHANGED
|
@@ -1,174 +1,126 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
1
|
+
import { existsSync } from "node:fs";
|
|
2
|
+
import { resolve } from "node:path";
|
|
3
|
+
import { addons, core as core$1 } from "@storybook/angular/preset";
|
|
4
|
+
import { fileURLToPath } from "node:url";
|
|
5
|
+
import * as vite from "vite";
|
|
6
|
+
import angular from "@analogjs/vite-plugin-angular";
|
|
7
|
+
//#region packages/storybook-angular/src/lib/preset.ts
|
|
8
|
+
var previewAnnotations = async (entries = [], options) => {
|
|
9
|
+
const config = fileURLToPath(import.meta.resolve("@storybook/angular/client/config"));
|
|
10
|
+
const annotations = [...entries, config];
|
|
11
|
+
if (options.enableProdMode) {
|
|
12
|
+
const previewProdPath = fileURLToPath(import.meta.resolve("@storybook/angular/client/preview-prod"));
|
|
13
|
+
annotations.unshift(previewProdPath);
|
|
14
|
+
}
|
|
15
|
+
const docsConfig = await options.presets.apply("docs", {}, options);
|
|
16
|
+
if (Object.keys(docsConfig).length > 0) {
|
|
17
|
+
const docsConfigPath = fileURLToPath(import.meta.resolve("@storybook/angular/client/docs/config"));
|
|
18
|
+
annotations.push(docsConfigPath);
|
|
19
|
+
}
|
|
20
|
+
return annotations;
|
|
18
21
|
};
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
22
|
+
var core = async (config, options) => {
|
|
23
|
+
const presetCore = await core$1(config, options);
|
|
24
|
+
return {
|
|
25
|
+
...presetCore,
|
|
26
|
+
builder: {
|
|
27
|
+
name: import.meta.resolve("@storybook/builder-vite"),
|
|
28
|
+
options: { ...presetCore.options }
|
|
29
|
+
}
|
|
30
|
+
};
|
|
28
31
|
};
|
|
29
32
|
async function resolveExperimentalZoneless(frameworkOptions, angularBuilderOptions) {
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
// 3. Auto-detect Angular 21+ (matches @storybook/angular builder behavior)
|
|
39
|
-
try {
|
|
40
|
-
const { VERSION } = await import('@angular/core');
|
|
41
|
-
return !!(VERSION.major && Number(VERSION.major) >= 21);
|
|
42
|
-
}
|
|
43
|
-
catch {
|
|
44
|
-
return false;
|
|
45
|
-
}
|
|
33
|
+
if (typeof frameworkOptions?.experimentalZoneless === "boolean") return frameworkOptions.experimentalZoneless;
|
|
34
|
+
if (typeof angularBuilderOptions?.experimentalZoneless === "boolean") return angularBuilderOptions.experimentalZoneless;
|
|
35
|
+
try {
|
|
36
|
+
const { VERSION } = await import("@angular/core");
|
|
37
|
+
return !!(VERSION.major && Number(VERSION.major) >= 21);
|
|
38
|
+
} catch {
|
|
39
|
+
return false;
|
|
40
|
+
}
|
|
46
41
|
}
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
? framework.options?.liveReload
|
|
78
|
-
: false,
|
|
79
|
-
tsconfig: typeof framework.options?.tsconfig !== 'undefined'
|
|
80
|
-
? framework.options?.tsconfig
|
|
81
|
-
: (options?.tsConfig ?? './.storybook/tsconfig.json'),
|
|
82
|
-
inlineStylesExtension: typeof framework.options?.inlineStylesExtension !== 'undefined'
|
|
83
|
-
? framework.options?.inlineStylesExtension
|
|
84
|
-
: 'css',
|
|
85
|
-
}),
|
|
86
|
-
angularOptionsPlugin(options, { normalizePath, experimentalZoneless }),
|
|
87
|
-
storybookEsbuildPlugin(),
|
|
88
|
-
],
|
|
89
|
-
define: {
|
|
90
|
-
STORYBOOK_ANGULAR_OPTIONS: JSON.stringify({
|
|
91
|
-
experimentalZoneless: !!experimentalZoneless,
|
|
92
|
-
}),
|
|
93
|
-
},
|
|
94
|
-
});
|
|
42
|
+
var viteFinal = async (config, options) => {
|
|
43
|
+
config.plugins = (config.plugins ?? []).flat().filter((plugin) => !plugin.name.includes("analogjs"));
|
|
44
|
+
const framework = await options.presets.apply("framework");
|
|
45
|
+
const experimentalZoneless = await resolveExperimentalZoneless(framework.options, options?.angularBuilderOptions);
|
|
46
|
+
return vite.mergeConfig(config, {
|
|
47
|
+
optimizeDeps: { include: [
|
|
48
|
+
"@storybook/angular/client",
|
|
49
|
+
"@analogjs/storybook-angular",
|
|
50
|
+
"@angular/compiler",
|
|
51
|
+
"@angular/platform-browser",
|
|
52
|
+
"@angular/platform-browser/animations",
|
|
53
|
+
"tslib",
|
|
54
|
+
...experimentalZoneless ? [] : ["zone.js"]
|
|
55
|
+
] },
|
|
56
|
+
resolve: { alias: { "@storybook/globalThis": "@storybook/global" } },
|
|
57
|
+
plugins: [
|
|
58
|
+
angular({
|
|
59
|
+
jit: typeof framework.options?.jit !== "undefined" ? framework.options?.jit : true,
|
|
60
|
+
liveReload: typeof framework.options?.liveReload !== "undefined" ? framework.options?.liveReload : false,
|
|
61
|
+
tsconfig: typeof framework.options?.tsconfig !== "undefined" ? framework.options?.tsconfig : options?.tsConfig ?? "./.storybook/tsconfig.json",
|
|
62
|
+
inlineStylesExtension: typeof framework.options?.inlineStylesExtension !== "undefined" ? framework.options?.inlineStylesExtension : "css"
|
|
63
|
+
}),
|
|
64
|
+
angularOptionsPlugin(options, {
|
|
65
|
+
normalizePath: vite.normalizePath,
|
|
66
|
+
experimentalZoneless
|
|
67
|
+
}),
|
|
68
|
+
storybookTransformConfigPlugin()
|
|
69
|
+
],
|
|
70
|
+
define: { STORYBOOK_ANGULAR_OPTIONS: JSON.stringify({ experimentalZoneless: !!experimentalZoneless }) }
|
|
71
|
+
});
|
|
95
72
|
};
|
|
96
73
|
function angularOptionsPlugin(options, { normalizePath, experimentalZoneless }) {
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
if (!experimentalZoneless) {
|
|
131
|
-
imports.push('zone.js');
|
|
132
|
-
}
|
|
133
|
-
// Use vite config root when angularBuilderContext is not available
|
|
134
|
-
// (e.g., when running via Vitest instead of Angular builders)
|
|
135
|
-
const projectRoot = resolvedConfig?.root ?? process.cwd();
|
|
136
|
-
return {
|
|
137
|
-
code: `
|
|
138
|
-
${imports
|
|
139
|
-
.map((extraImport) => {
|
|
140
|
-
if (extraImport.startsWith('.') ||
|
|
141
|
-
extraImport.startsWith('src')) {
|
|
142
|
-
// relative to root
|
|
143
|
-
return `import '${resolve(projectRoot, extraImport)}';`;
|
|
144
|
-
}
|
|
145
|
-
// absolute import
|
|
146
|
-
return `import '${extraImport}';`;
|
|
147
|
-
})
|
|
148
|
-
.join('\n')}
|
|
74
|
+
let resolvedConfig;
|
|
75
|
+
return {
|
|
76
|
+
name: "analogjs-storybook-options-plugin",
|
|
77
|
+
config(userConfig) {
|
|
78
|
+
resolvedConfig = userConfig;
|
|
79
|
+
const loadPaths = options?.angularBuilderOptions?.stylePreprocessorOptions?.loadPaths;
|
|
80
|
+
const sassOptions = options?.angularBuilderOptions?.stylePreprocessorOptions?.sass;
|
|
81
|
+
if (Array.isArray(loadPaths)) {
|
|
82
|
+
const workspaceRoot = options.angularBuilderContext?.workspaceRoot ?? userConfig?.root ?? process.cwd();
|
|
83
|
+
return { css: { preprocessorOptions: { scss: {
|
|
84
|
+
...sassOptions,
|
|
85
|
+
loadPaths: loadPaths.map((loadPath) => `${resolve(workspaceRoot, loadPath)}`)
|
|
86
|
+
} } } };
|
|
87
|
+
}
|
|
88
|
+
},
|
|
89
|
+
async transform(code, id) {
|
|
90
|
+
if (normalizePath(id).endsWith(normalizePath(`${options.configDir}/preview.ts`))) {
|
|
91
|
+
const imports = [];
|
|
92
|
+
const styles = options?.angularBuilderOptions?.styles;
|
|
93
|
+
const workspaceRoot = options?.angularBuilderContext?.workspaceRoot ?? process.cwd();
|
|
94
|
+
if (Array.isArray(styles)) styles.forEach((style) => {
|
|
95
|
+
imports.push(style);
|
|
96
|
+
});
|
|
97
|
+
if (!experimentalZoneless) imports.push("zone.js");
|
|
98
|
+
const projectRoot = resolvedConfig?.root ?? process.cwd();
|
|
99
|
+
return { code: `
|
|
100
|
+
${imports.map((extraImport) => {
|
|
101
|
+
const resolvedProjectImport = resolve(projectRoot, extraImport);
|
|
102
|
+
const resolvedWorkspaceImport = resolve(workspaceRoot, extraImport);
|
|
103
|
+
if (extraImport.startsWith(".") || extraImport.startsWith("src") || existsSync(resolvedProjectImport)) return `import '${resolvedProjectImport}';`;
|
|
104
|
+
if (existsSync(resolvedWorkspaceImport)) return `import '${resolvedWorkspaceImport}';`;
|
|
105
|
+
return `import '${extraImport}';`;
|
|
106
|
+
}).join("\n")}
|
|
149
107
|
${code}
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
},
|
|
155
|
-
};
|
|
108
|
+
` };
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
};
|
|
156
112
|
}
|
|
157
|
-
function
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
keepNames: true,
|
|
167
|
-
},
|
|
168
|
-
};
|
|
169
|
-
},
|
|
170
|
-
};
|
|
113
|
+
function storybookTransformConfigPlugin() {
|
|
114
|
+
const configKey = vite.rolldownVersion ? "oxc" : "esbuild";
|
|
115
|
+
return {
|
|
116
|
+
name: "analogjs-storybook-transform-config",
|
|
117
|
+
apply: "build",
|
|
118
|
+
config() {
|
|
119
|
+
return { [configKey]: { keepNames: true } };
|
|
120
|
+
}
|
|
121
|
+
};
|
|
171
122
|
}
|
|
172
|
-
|
|
173
|
-
|
|
123
|
+
//#endregion
|
|
124
|
+
export { addons, core, previewAnnotations, viteFinal };
|
|
125
|
+
|
|
174
126
|
//# sourceMappingURL=preset.js.map
|
package/src/lib/preset.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"preset.js","sourceRoot":"","sources":["../../../../../packages/storybook-angular/src/lib/preset.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,EAAE,IAAI,IAAI,UAAU,EAAE,MAAM,2BAA2B,CAAC;AAC/D,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AAEzC,MAAM,CAAC,MAAM,kBAAkB,GAAG,KAAK,EAAE,OAAO,GAAG,EAAE,EAAE,OAAO,EAAE,EAAE;IAChE,MAAM,MAAM,GAAG,aAAa,CAC1B,MAAM,CAAC,IAAI,CAAC,OAAO,CAAC,kCAAkC,CAAC,CACxD,CAAC;IACF,MAAM,WAAW,GAAG,CAAC,GAAG,OAAO,EAAE,MAAM,CAAC,CAAC;IAEzC,IAAI,OAAO,CAAC,cAAc,EAAE,CAAC;QAC3B,MAAM,eAAe,GAAG,aAAa,CACnC,M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F,OAAO;yBACN,GAAG,CAAC,CAAC,WAAW,EAAE,EAAE;wBACnB,IACE,WAAW,CAAC,UAAU,CAAC,GAAG,CAAC;4BAC3B,WAAW,CAAC,UAAU,CAAC,KAAK,CAAC,EAC7B,CAAC;4BACD,mBAAmB;4BACnB,OAAO,WAAW,OAAO,CAAC,WAAW,EAAE,WAAW,CAAC,IAAI,CAAC;wBAC1D,CAAC;wBAED,kBAAkB;wBAClB,OAAO,WAAW,WAAW,IAAI,CAAC;oBACpC,CAAC,CAAC;yBACD,IAAI,CAAC,IAAI,CAAC;cACX,IAAI;WACP;iBACF,CAAC;YACJ,CAAC;YAED,OAAO;QACT,CAAC;KACF,CAAC;AACJ,CAAC;AAED,SAAS,sBAAsB;IAC7B,OAAO;QACL,IAAI,EAAE,mCAAmC;QACzC,KAAK,EAAE,OAAO;QACd,MAAM;YACJ,OAAO;gBACL,OAAO,EAAE;oBACP,4CAA4C;oBAC5C,0CAA0C;oBAC1C,SAAS,EAAE,IAAI;iBAChB;aACF,CAAC;QACJ,CAAC;KACF,CAAC;AACJ,CAAC;AAED,OAAO,EAAE,MAAM,EAAE,MAAM,2BAA2B,CAAC;AACnD,kCAAkC"}
|
|
1
|
+
{"version":3,"file":"preset.js","names":[],"sources":["../../../src/lib/preset.ts"],"sourcesContent":["import { existsSync } from 'node:fs';\nimport { resolve } from 'node:path';\nimport { core as PresetCore } from '@storybook/angular/preset';\nimport { fileURLToPath } from 'node:url';\nimport * as vite from 'vite';\nimport type { Plugin, UserConfig } from 'vite';\nimport angular from '@analogjs/vite-plugin-angular';\n\nexport const previewAnnotations = async (\n entries: string[] = [],\n options: any,\n): Promise<string[]> => {\n const config = fileURLToPath(\n import.meta.resolve('@storybook/angular/client/config'),\n );\n const annotations = [...entries, config];\n\n if (options.enableProdMode) {\n const previewProdPath = fileURLToPath(\n import.meta.resolve('@storybook/angular/client/preview-prod'),\n );\n annotations.unshift(previewProdPath);\n }\n\n const docsConfig = await options.presets.apply('docs', {}, options);\n const docsEnabled = Object.keys(docsConfig).length > 0;\n if (docsEnabled) {\n const docsConfigPath = fileURLToPath(\n import.meta.resolve('@storybook/angular/client/docs/config'),\n );\n annotations.push(docsConfigPath);\n }\n return annotations;\n};\n\nexport const core = async (config: any, options: any): Promise<any> => {\n const presetCore = await PresetCore(config, options);\n return {\n ...presetCore,\n builder: {\n name: import.meta.resolve('@storybook/builder-vite'),\n options: { ...presetCore.options },\n },\n };\n};\n\nasync function resolveExperimentalZoneless(\n frameworkOptions: any,\n angularBuilderOptions: any,\n) {\n // 1. Explicit framework option (user's .storybook/main.ts)\n if (typeof frameworkOptions?.experimentalZoneless === 'boolean') {\n return frameworkOptions.experimentalZoneless;\n }\n\n // 2. Angular builder options (set by start-storybook/build-storybook)\n if (typeof angularBuilderOptions?.experimentalZoneless === 'boolean') {\n return angularBuilderOptions.experimentalZoneless;\n }\n\n // 3. Auto-detect Angular 21+ (matches @storybook/angular builder behavior)\n try {\n const { VERSION } = await import('@angular/core');\n return !!(VERSION.major && Number(VERSION.major) >= 21);\n } catch {\n return false;\n }\n}\n\nexport const viteFinal = async (config: any, options: any): Promise<any> => {\n // Remove any loaded analogjs plugins from a vite.config.(m)ts file\n config.plugins = (config.plugins ?? [])\n .flat()\n .filter((plugin: any) => !plugin.name.includes('analogjs'));\n\n // @ts-expect-error - untyped storybook presets API\n const framework = await options.presets.apply('framework');\n const experimentalZoneless = await resolveExperimentalZoneless(\n framework.options,\n options?.angularBuilderOptions,\n );\n return vite.mergeConfig(config, {\n // Add dependencies to pre-optimization\n optimizeDeps: {\n include: [\n '@storybook/angular/client',\n '@analogjs/storybook-angular',\n '@angular/compiler',\n '@angular/platform-browser',\n '@angular/platform-browser/animations',\n 'tslib',\n ...(experimentalZoneless ? [] : ['zone.js']),\n ],\n },\n resolve: {\n alias: {\n '@storybook/globalThis': '@storybook/global',\n },\n },\n plugins: [\n angular({\n jit:\n typeof framework.options?.jit !== 'undefined'\n ? framework.options?.jit\n : true,\n liveReload:\n typeof framework.options?.liveReload !== 'undefined'\n ? framework.options?.liveReload\n : false,\n tsconfig:\n typeof framework.options?.tsconfig !== 'undefined'\n ? framework.options?.tsconfig\n : (options?.tsConfig ?? './.storybook/tsconfig.json'),\n inlineStylesExtension:\n typeof framework.options?.inlineStylesExtension !== 'undefined'\n ? framework.options?.inlineStylesExtension\n : 'css',\n }),\n angularOptionsPlugin(options, {\n normalizePath: vite.normalizePath,\n experimentalZoneless,\n }),\n storybookTransformConfigPlugin(),\n ],\n define: {\n STORYBOOK_ANGULAR_OPTIONS: JSON.stringify({\n experimentalZoneless: !!experimentalZoneless,\n }),\n },\n });\n};\n\nfunction angularOptionsPlugin(\n options: any,\n {\n normalizePath,\n experimentalZoneless,\n }: { normalizePath: (path: string) => string; experimentalZoneless: boolean },\n): Plugin {\n let resolvedConfig: UserConfig | undefined;\n return {\n name: 'analogjs-storybook-options-plugin',\n config(userConfig: UserConfig) {\n resolvedConfig = userConfig;\n const loadPaths =\n options?.angularBuilderOptions?.stylePreprocessorOptions?.loadPaths;\n const sassOptions =\n options?.angularBuilderOptions?.stylePreprocessorOptions?.sass;\n\n if (Array.isArray(loadPaths)) {\n const workspaceRoot =\n options.angularBuilderContext?.workspaceRoot ??\n userConfig?.root ??\n process.cwd();\n return {\n css: {\n preprocessorOptions: {\n scss: {\n ...sassOptions,\n loadPaths: loadPaths.map(\n (loadPath) => `${resolve(workspaceRoot, loadPath)}`,\n ),\n },\n },\n },\n };\n }\n\n return;\n },\n async transform(code: string, id: string) {\n if (\n normalizePath(id).endsWith(\n normalizePath(`${options.configDir}/preview.ts`),\n )\n ) {\n const imports = [];\n const styles = options?.angularBuilderOptions?.styles;\n const workspaceRoot =\n options?.angularBuilderContext?.workspaceRoot ?? process.cwd();\n\n if (Array.isArray(styles)) {\n styles.forEach((style) => {\n imports.push(style);\n });\n }\n\n if (!experimentalZoneless) {\n imports.push('zone.js');\n }\n\n // Use vite config root when angularBuilderContext is not available\n // (e.g., when running via Vitest instead of Angular builders)\n const projectRoot = resolvedConfig?.root ?? process.cwd();\n\n return {\n code: `\n ${imports\n .map((extraImport) => {\n const resolvedProjectImport = resolve(projectRoot, extraImport);\n const resolvedWorkspaceImport = resolve(\n workspaceRoot,\n extraImport,\n );\n\n if (\n extraImport.startsWith('.') ||\n extraImport.startsWith('src') ||\n existsSync(resolvedProjectImport)\n ) {\n // relative to root\n return `import '${resolvedProjectImport}';`;\n }\n\n if (existsSync(resolvedWorkspaceImport)) {\n return `import '${resolvedWorkspaceImport}';`;\n }\n\n // absolute import\n return `import '${extraImport}';`;\n })\n .join('\\n')}\n ${code}\n `,\n };\n }\n\n return;\n },\n };\n}\n\nfunction storybookTransformConfigPlugin(): Plugin {\n const configKey = vite.rolldownVersion ? 'oxc' : 'esbuild';\n\n return {\n name: 'analogjs-storybook-transform-config',\n apply: 'build',\n config() {\n return {\n [configKey]: {\n // Don't mangle class names during the build\n // This fixes display of compodoc argtypes\n keepNames: true,\n },\n };\n },\n };\n}\n\nexport { addons } from '@storybook/angular/preset';\n"],"mappings":";;;;;;;AAQA,IAAa,qBAAqB,OAChC,UAAoB,EAAE,EACtB,YACsB;CACtB,MAAM,SAAS,cACb,OAAO,KAAK,QAAQ,mCAAmC,CACxD;CACD,MAAM,cAAc,CAAC,GAAG,SAAS,OAAO;AAExC,KAAI,QAAQ,gBAAgB;EAC1B,MAAM,kBAAkB,cACtB,OAAO,KAAK,QAAQ,yCAAyC,CAC9D;AACD,cAAY,QAAQ,gBAAgB;;CAGtC,MAAM,aAAa,MAAM,QAAQ,QAAQ,MAAM,QAAQ,EAAE,EAAE,QAAQ;AAEnE,KADoB,OAAO,KAAK,WAAW,CAAC,SAAS,GACpC;EACf,MAAM,iBAAiB,cACrB,OAAO,KAAK,QAAQ,wCAAwC,CAC7D;AACD,cAAY,KAAK,eAAe;;AAElC,QAAO;;AAGT,IAAa,OAAO,OAAO,QAAa,YAA+B;CACrE,MAAM,aAAa,MAAM,OAAW,QAAQ,QAAQ;AACpD,QAAO;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;aAEV;;;EAKN;;AAGH,SAAS,iCAAyC;CAChD,MAAM,YAAY,KAAK,kBAAkB,QAAQ;AAEjD,QAAO;EACL,MAAM;EACN,OAAO;EACP,SAAS;AACP,UAAO,GACJ,YAAY,EAGX,WAAW,MACZ,EACF;;EAEJ"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import StartStorybookBuilder from
|
|
1
|
+
import StartStorybookBuilder from "@storybook/angular/builders/start-storybook";
|
|
2
2
|
export default StartStorybookBuilder;
|
|
@@ -1,3 +1,7 @@
|
|
|
1
|
-
import StartStorybookBuilder from
|
|
2
|
-
|
|
1
|
+
import StartStorybookBuilder from "@storybook/angular/builders/start-storybook";
|
|
2
|
+
//#region packages/storybook-angular/src/lib/start-storybook/start-storybook.ts
|
|
3
|
+
var start_storybook_default = StartStorybookBuilder;
|
|
4
|
+
//#endregion
|
|
5
|
+
export { start_storybook_default as default };
|
|
6
|
+
|
|
3
7
|
//# sourceMappingURL=start-storybook.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"start-storybook.js","
|
|
1
|
+
{"version":3,"file":"start-storybook.js","names":[],"sources":["../../../../src/lib/start-storybook/start-storybook.ts"],"sourcesContent":["import StartStorybookBuilder from '@storybook/angular/builders/start-storybook';\n\nexport default StartStorybookBuilder;\n"],"mappings":";;AAEA,IAAA,0BAAe"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Ambient declarations for @storybook/angular subpath imports that do NOT ship types.
|
|
3
|
+
* Official @storybook/angular does not provide .d.ts files for builders, preset, client, etc.
|
|
4
|
+
* Tracked in various GitHub issues since ~2018–2023.
|
|
5
|
+
* See also: https://github.com/storybookjs/storybook/issues?q=is%3Aissue+angular+types+is%3Aopen
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
declare module '@storybook/angular/builders/build-storybook';
|
|
9
|
+
declare module '@storybook/angular/builders/start-storybook';
|
|
10
|
+
declare module '@storybook/angular/preset';
|
|
11
|
+
declare module '@storybook/angular/client';
|
|
12
|
+
declare module '@storybook/angular/client/config';
|
package/src/lib/testing.d.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
import
|
|
2
|
-
import type { AngularRenderer } from
|
|
3
|
-
import { NamedOrDefaultProjectAnnotations, NormalizedProjectAnnotations, RenderContext } from
|
|
4
|
-
|
|
1
|
+
import "@angular/compiler";
|
|
2
|
+
import type { AngularRenderer } from "@storybook/angular";
|
|
3
|
+
import { NamedOrDefaultProjectAnnotations, NormalizedProjectAnnotations, RenderContext } from "storybook/internal/types";
|
|
4
|
+
import * as configAnnotations from "@storybook/angular/client/config";
|
|
5
|
+
export declare const render: typeof configAnnotations.render;
|
|
5
6
|
export declare function renderToCanvas(context: RenderContext<AngularRenderer>, element: HTMLElement): Promise<void>;
|
|
6
7
|
export declare function setProjectAnnotations(projectAnnotations: NamedOrDefaultProjectAnnotations<any> | NamedOrDefaultProjectAnnotations<any>[]): NormalizedProjectAnnotations<AngularRenderer>;
|
package/src/lib/testing.js
CHANGED
|
@@ -1,21 +1,20 @@
|
|
|
1
|
-
import
|
|
2
|
-
import { setProjectAnnotations as
|
|
3
|
-
import * as configAnnotations from
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
1
|
+
import "@angular/compiler";
|
|
2
|
+
import { setProjectAnnotations as setProjectAnnotations$1 } from "@storybook/angular/client";
|
|
3
|
+
import * as configAnnotations from "@storybook/angular/client/config";
|
|
4
|
+
//#region packages/storybook-angular/src/lib/testing.ts
|
|
5
|
+
var render = configAnnotations.render;
|
|
6
|
+
async function renderToCanvas(context, element) {
|
|
7
|
+
element.id = context.id;
|
|
8
|
+
await configAnnotations.renderToCanvas(context, element);
|
|
8
9
|
}
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
10
|
+
var renderAnnotations = {
|
|
11
|
+
render,
|
|
12
|
+
renderToCanvas
|
|
12
13
|
};
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
renderAnnotations,
|
|
16
|
-
...(Array.isArray(projectAnnotations)
|
|
17
|
-
? projectAnnotations
|
|
18
|
-
: [projectAnnotations]),
|
|
19
|
-
]);
|
|
14
|
+
function setProjectAnnotations(projectAnnotations) {
|
|
15
|
+
return setProjectAnnotations$1([renderAnnotations, ...Array.isArray(projectAnnotations) ? projectAnnotations : [projectAnnotations]]);
|
|
20
16
|
}
|
|
17
|
+
//#endregion
|
|
18
|
+
export { render, renderToCanvas, setProjectAnnotations };
|
|
19
|
+
|
|
21
20
|
//# sourceMappingURL=testing.js.map
|
package/src/lib/testing.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"testing.js","
|
|
1
|
+
{"version":3,"file":"testing.js","names":[],"sources":["../../../src/lib/testing.ts"],"sourcesContent":["import '@angular/compiler';\nimport type { AngularRenderer } from '@storybook/angular';\nimport { setProjectAnnotations as originalSetProjectAnnotations } from '@storybook/angular/client';\nimport {\n NamedOrDefaultProjectAnnotations,\n NormalizedProjectAnnotations,\n RenderContext,\n} from 'storybook/internal/types';\nimport * as configAnnotations from '@storybook/angular/client/config';\n\nexport const render: typeof configAnnotations.render = configAnnotations.render;\n\nexport async function renderToCanvas(\n context: RenderContext<AngularRenderer>,\n element: HTMLElement,\n): Promise<void> {\n element.id = context.id;\n await configAnnotations.renderToCanvas(context, element);\n}\n\nconst renderAnnotations = {\n render,\n renderToCanvas,\n};\n\nexport function setProjectAnnotations(\n projectAnnotations:\n | NamedOrDefaultProjectAnnotations<any>\n | NamedOrDefaultProjectAnnotations<any>[],\n): NormalizedProjectAnnotations<AngularRenderer> {\n return originalSetProjectAnnotations([\n renderAnnotations,\n ...(Array.isArray(projectAnnotations)\n ? projectAnnotations\n : [projectAnnotations]),\n ]) as NormalizedProjectAnnotations<AngularRenderer>;\n}\n"],"mappings":";;;;AAUA,IAAa,SAA0C,kBAAkB;AAEzE,eAAsB,eACpB,SACA,SACe;AACf,SAAQ,KAAK,QAAQ;AACrB,OAAM,kBAAkB,eAAe,SAAS,QAAQ;;AAG1D,IAAM,oBAAoB;CACxB;CACA;CACD;AAED,SAAgB,sBACd,oBAG+C;AAC/C,QAAO,wBAA8B,CACnC,mBACA,GAAI,MAAM,QAAQ,mBAAmB,GACjC,qBACA,CAAC,mBAAmB,CACzB,CAAC"}
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { BuilderOptions, CLIOptions, LoadOptions } from
|
|
1
|
+
import { BuilderOptions, CLIOptions, LoadOptions } from "storybook/internal/types";
|
|
2
2
|
export type StandaloneOptions = CLIOptions & LoadOptions & BuilderOptions & {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
3
|
+
mode?: "static" | "dev";
|
|
4
|
+
enableProdMode: boolean;
|
|
5
|
+
angularBuilderOptions?: Record<string, any> & {
|
|
6
|
+
experimentalZoneless?: boolean;
|
|
7
|
+
};
|
|
8
|
+
tsConfig?: string;
|
|
9
9
|
};
|
package/src/types.d.ts
CHANGED
|
@@ -1,27 +1,27 @@
|
|
|
1
|
-
import { CompatibleString } from
|
|
2
|
-
import { StorybookConfig as StorybookConfigBase } from
|
|
3
|
-
import { BuilderOptions, StorybookConfigVite } from
|
|
4
|
-
type FrameworkName = CompatibleString<
|
|
5
|
-
type BuilderName = CompatibleString<
|
|
1
|
+
import { CompatibleString } from "storybook/internal/types";
|
|
2
|
+
import { StorybookConfig as StorybookConfigBase } from "@storybook/angular";
|
|
3
|
+
import { BuilderOptions, StorybookConfigVite } from "@storybook/builder-vite";
|
|
4
|
+
type FrameworkName = CompatibleString<"@analogjs/storybook-angular">;
|
|
5
|
+
type BuilderName = CompatibleString<"@storybook/builder-vite">;
|
|
6
6
|
export type FrameworkOptions = {
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
7
|
+
builder?: BuilderOptions;
|
|
8
|
+
jit?: boolean;
|
|
9
|
+
liveReload?: boolean;
|
|
10
|
+
inlineStylesExtension?: string;
|
|
11
|
+
tsconfig?: string;
|
|
12
|
+
experimentalZoneless?: boolean;
|
|
13
13
|
};
|
|
14
14
|
type StorybookConfigFramework = {
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
15
|
+
framework: FrameworkName | {
|
|
16
|
+
name: FrameworkName;
|
|
17
|
+
options: FrameworkOptions;
|
|
18
|
+
};
|
|
19
|
+
core?: StorybookConfigBase["core"] & {
|
|
20
|
+
builder?: BuilderName | {
|
|
21
|
+
name: BuilderName;
|
|
22
|
+
options: BuilderOptions;
|
|
23
|
+
};
|
|
24
|
+
};
|
|
25
25
|
};
|
|
26
26
|
/** The interface for Storybook configuration in `main.ts` files. */
|
|
27
27
|
export type StorybookConfig = Omit<StorybookConfigBase, keyof StorybookConfigVite | keyof StorybookConfigFramework> & StorybookConfigVite & StorybookConfigFramework;
|
package/README.md
DELETED
|
@@ -1,270 +0,0 @@
|
|
|
1
|
-
# @analogjs/storybook-angular
|
|
2
|
-
|
|
3
|
-
Integration package for Storybook using Angular & Vite.
|
|
4
|
-
|
|
5
|
-
> This is a community integration not maintained by the Storybook team. If you have issues,
|
|
6
|
-
> file an issue in our [GitHub repo](https://github.com/analogjs/analog/issues).
|
|
7
|
-
|
|
8
|
-
## Setup
|
|
9
|
-
|
|
10
|
-
If you don't have Storybook setup already, run the following command to initialize Storybook for your project:
|
|
11
|
-
|
|
12
|
-
```sh
|
|
13
|
-
npx storybook@latest init
|
|
14
|
-
```
|
|
15
|
-
|
|
16
|
-
Follow the provided prompts, and commit your changes.
|
|
17
|
-
|
|
18
|
-
## Installing the Storybook package
|
|
19
|
-
|
|
20
|
-
Install the Storybook Plugin for Angular and Vite. Depending on your preferred package manager, run one of the following commands:
|
|
21
|
-
|
|
22
|
-
```shell
|
|
23
|
-
npm install @analogjs/storybook-angular --save-dev
|
|
24
|
-
```
|
|
25
|
-
|
|
26
|
-
## Configuring Storybook
|
|
27
|
-
|
|
28
|
-
Update the `.storybook/main.ts` file to use the `StorybookConfig` type. Also update the `framework` to use the `@analogjs/storybook-angular` package.
|
|
29
|
-
|
|
30
|
-
```ts
|
|
31
|
-
import { StorybookConfig } from '@analogjs/storybook-angular';
|
|
32
|
-
|
|
33
|
-
const config: StorybookConfig = {
|
|
34
|
-
// other config, addons, etc.
|
|
35
|
-
framework: {
|
|
36
|
-
name: '@analogjs/storybook-angular',
|
|
37
|
-
options: {},
|
|
38
|
-
},
|
|
39
|
-
};
|
|
40
|
-
|
|
41
|
-
export default config;
|
|
42
|
-
```
|
|
43
|
-
|
|
44
|
-
Remove the existing `webpackFinal` config function if present.
|
|
45
|
-
|
|
46
|
-
Next, update the Storybook targets in the `angular.json` or `project.json`
|
|
47
|
-
|
|
48
|
-
```json
|
|
49
|
-
"storybook": {
|
|
50
|
-
"builder": "@analogjs/storybook-angular:start-storybook",
|
|
51
|
-
},
|
|
52
|
-
"build-storybook": {
|
|
53
|
-
"builder": "@analogjs/storybook-angular:build-storybook"
|
|
54
|
-
}
|
|
55
|
-
```
|
|
56
|
-
|
|
57
|
-
Remove any `webpack` specific options and remove the `browserTarget` option.
|
|
58
|
-
|
|
59
|
-
Add the `/storybook-static` folder to the `.gitignore` file.
|
|
60
|
-
|
|
61
|
-
## Setting up CSS
|
|
62
|
-
|
|
63
|
-
To register global styles, add them to the `@analogjs/storybook-angular` builder options in the `angular.json` or `project.json`.
|
|
64
|
-
|
|
65
|
-
```json
|
|
66
|
-
"storybook": {
|
|
67
|
-
"builder": "@analogjs/storybook-angular:start-storybook",
|
|
68
|
-
"options": {
|
|
69
|
-
// ... other options
|
|
70
|
-
"styles": [
|
|
71
|
-
"src/styles.css"
|
|
72
|
-
],
|
|
73
|
-
"stylePreprocessorOptions": {
|
|
74
|
-
"loadPaths": ["libs/my-lib/styles"]
|
|
75
|
-
}
|
|
76
|
-
}
|
|
77
|
-
},
|
|
78
|
-
"build-storybook": {
|
|
79
|
-
"builder": "@analogjs/storybook-angular:build-storybook",
|
|
80
|
-
"options": {
|
|
81
|
-
// ... other options
|
|
82
|
-
"styles": [
|
|
83
|
-
"src/styles.css"
|
|
84
|
-
],
|
|
85
|
-
"stylePreprocessorOptions": {
|
|
86
|
-
"loadPaths": ["libs/my-lib/styles"]
|
|
87
|
-
}
|
|
88
|
-
}
|
|
89
|
-
}
|
|
90
|
-
```
|
|
91
|
-
|
|
92
|
-
## Enabling Zoneless Change Detection
|
|
93
|
-
|
|
94
|
-
To use zoneless change detection for the Storybook, add the `experimentalZoneless` flag to the `@analogjs/storybook-angular` builder options in the `angular.json`.
|
|
95
|
-
|
|
96
|
-
```json
|
|
97
|
-
"storybook": {
|
|
98
|
-
"builder": "@analogjs/storybook-angular:start-storybook",
|
|
99
|
-
"options": {
|
|
100
|
-
// ... other options
|
|
101
|
-
"experimentalZoneless": true
|
|
102
|
-
}
|
|
103
|
-
},
|
|
104
|
-
"build-storybook": {
|
|
105
|
-
"builder": "@analogjs/storybook-angular:build-storybook",
|
|
106
|
-
"options": {
|
|
107
|
-
// ... other options
|
|
108
|
-
"experimentalZoneless": true
|
|
109
|
-
}
|
|
110
|
-
}
|
|
111
|
-
```
|
|
112
|
-
|
|
113
|
-
For `project.json`
|
|
114
|
-
|
|
115
|
-
```json
|
|
116
|
-
"storybook": {
|
|
117
|
-
"executor": "@analogjs/storybook-angular:start-storybook",
|
|
118
|
-
"options": {
|
|
119
|
-
// ... other options
|
|
120
|
-
"configDir": "path/to/.storybook",
|
|
121
|
-
"experimentalZoneless": true,
|
|
122
|
-
"compodoc": false
|
|
123
|
-
}
|
|
124
|
-
},
|
|
125
|
-
"build-storybook": {
|
|
126
|
-
"executor": "@analogjs/storybook-angular:build-storybook",
|
|
127
|
-
"options": {
|
|
128
|
-
// ... other options
|
|
129
|
-
"configDir": "path/to/.storybook",
|
|
130
|
-
"experimentalZoneless": true,
|
|
131
|
-
"compodoc": false
|
|
132
|
-
}
|
|
133
|
-
}
|
|
134
|
-
```
|
|
135
|
-
|
|
136
|
-
> Zoneless change detection is the default for new projects starting Angular v21.
|
|
137
|
-
|
|
138
|
-
## Setting up Static Assets
|
|
139
|
-
|
|
140
|
-
Static assets are configured in the `.storybook/main.ts` file using the `staticDirs` array.
|
|
141
|
-
|
|
142
|
-
The example below shows how to add the `public` directory from `src/public` relative to the `.storybook/main.ts` file.
|
|
143
|
-
|
|
144
|
-
```ts
|
|
145
|
-
import { StorybookConfig } from '@analogjs/storybook-angular';
|
|
146
|
-
|
|
147
|
-
const config: StorybookConfig = {
|
|
148
|
-
// other config, addons, etc.
|
|
149
|
-
framework: {
|
|
150
|
-
name: '@analogjs/storybook-angular',
|
|
151
|
-
options: {},
|
|
152
|
-
},
|
|
153
|
-
staticDirs: ['../public'],
|
|
154
|
-
};
|
|
155
|
-
|
|
156
|
-
export default config;
|
|
157
|
-
```
|
|
158
|
-
|
|
159
|
-
See the [Storybook docs on images and assets](https://storybook.js.org/docs/configure/integration/images-and-assets) for more information.
|
|
160
|
-
|
|
161
|
-
## Running Storybook
|
|
162
|
-
|
|
163
|
-
Run the command for starting the development server.
|
|
164
|
-
|
|
165
|
-
```sh
|
|
166
|
-
npm run storybook
|
|
167
|
-
```
|
|
168
|
-
|
|
169
|
-
## Building Storybook
|
|
170
|
-
|
|
171
|
-
Run the command for building the storybook.
|
|
172
|
-
|
|
173
|
-
```sh
|
|
174
|
-
npm run build-storybook
|
|
175
|
-
```
|
|
176
|
-
|
|
177
|
-
## Using TypeScript Config Path Aliases
|
|
178
|
-
|
|
179
|
-
If you are using `paths` in your `tsconfig.json`, support for those aliases can be added to the `vite.config.ts`.
|
|
180
|
-
|
|
181
|
-
### With Angular CLI
|
|
182
|
-
|
|
183
|
-
First, install the `vite-tsconfig-paths` package.
|
|
184
|
-
|
|
185
|
-
```shell
|
|
186
|
-
npm install vite-tsconfig-paths --save-dev
|
|
187
|
-
```
|
|
188
|
-
|
|
189
|
-
Next, add the plugin to the `plugins` array in the `.storybook/main.ts`.
|
|
190
|
-
|
|
191
|
-
```ts
|
|
192
|
-
import viteTsConfigPaths from 'vite-tsconfig-paths';
|
|
193
|
-
import { UserConfig, mergeConfig } from 'vite';
|
|
194
|
-
|
|
195
|
-
import type { StorybookConfig } from '@analogjs/storybook-angular';
|
|
196
|
-
|
|
197
|
-
const config: StorybookConfig = {
|
|
198
|
-
// ... other config, addons, etc.
|
|
199
|
-
async viteFinal(config: UserConfig) {
|
|
200
|
-
return mergeConfig(config, {
|
|
201
|
-
plugins: [viteTsConfigPaths()],
|
|
202
|
-
});
|
|
203
|
-
},
|
|
204
|
-
};
|
|
205
|
-
|
|
206
|
-
export default config;
|
|
207
|
-
```
|
|
208
|
-
|
|
209
|
-
### With Nx
|
|
210
|
-
|
|
211
|
-
For Nx workspaces, import and use the `nxViteTsPaths` plugin from the `@nx/vite` package. Add the plugin to the `plugins` array in the `.storybook/main.ts`.
|
|
212
|
-
|
|
213
|
-
```ts
|
|
214
|
-
import { nxViteTsPaths } from '@nx/vite/plugins/nx-tsconfig-paths.plugin';
|
|
215
|
-
import { UserConfig, mergeConfig } from 'vite';
|
|
216
|
-
|
|
217
|
-
import type { StorybookConfig } from '@analogjs/storybook-angular';
|
|
218
|
-
|
|
219
|
-
const config: StorybookConfig = {
|
|
220
|
-
// ... other config, addons, etc.
|
|
221
|
-
async viteFinal(config: UserConfig) {
|
|
222
|
-
return mergeConfig(config, {
|
|
223
|
-
plugins: [nxViteTsPaths()],
|
|
224
|
-
});
|
|
225
|
-
},
|
|
226
|
-
};
|
|
227
|
-
|
|
228
|
-
export default config;
|
|
229
|
-
```
|
|
230
|
-
|
|
231
|
-
## Using File Replacements
|
|
232
|
-
|
|
233
|
-
You can also use the `replaceFiles()` plugin from Nx to replace files during your build.
|
|
234
|
-
|
|
235
|
-
Import the plugin and set it up:
|
|
236
|
-
|
|
237
|
-
```ts
|
|
238
|
-
import { replaceFiles } from '@nx/vite/plugins/rollup-replace-files.plugin';
|
|
239
|
-
import { UserConfig, mergeConfig } from 'vite';
|
|
240
|
-
|
|
241
|
-
import type { StorybookConfig } from '@analogjs/storybook-angular';
|
|
242
|
-
|
|
243
|
-
const config: StorybookConfig = {
|
|
244
|
-
// ... other config, addons, etc.
|
|
245
|
-
async viteFinal(config: UserConfig) {
|
|
246
|
-
return mergeConfig(config, {
|
|
247
|
-
plugins: [
|
|
248
|
-
replaceFiles([
|
|
249
|
-
{
|
|
250
|
-
replace: './src/one.ts',
|
|
251
|
-
with: './src/two.ts',
|
|
252
|
-
},
|
|
253
|
-
]),
|
|
254
|
-
],
|
|
255
|
-
});
|
|
256
|
-
},
|
|
257
|
-
};
|
|
258
|
-
|
|
259
|
-
export default config;
|
|
260
|
-
```
|
|
261
|
-
|
|
262
|
-
Adding the replacement files to `files` array in the `tsconfig.app.json` may also be necessary.
|
|
263
|
-
|
|
264
|
-
```json
|
|
265
|
-
{
|
|
266
|
-
"extends": "./tsconfig.json",
|
|
267
|
-
// other config
|
|
268
|
-
"files": ["src/main.ts", "src/main.server.ts", "src/two.ts"]
|
|
269
|
-
}
|
|
270
|
-
```
|
package/src/index.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../packages/storybook-angular/src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAYL,iBAAiB,EACjB,cAAc,EACd,yBAAyB,EACzB,cAAc,EACd,qBAAqB,GACtB,MAAM,oBAAoB,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
//# sourceMappingURL=standalone-options.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"standalone-options.js","sourceRoot":"","sources":["../../../../../../packages/storybook-angular/src/lib/utils/standalone-options.ts"],"names":[],"mappings":""}
|
package/src/types.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
//# sourceMappingURL=types.js.map
|
package/src/types.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../../../packages/storybook-angular/src/types.ts"],"names":[],"mappings":""}
|