Skip to content

Commit 4017d26

Browse files
build: migrate soba Storybook to Vite
1 parent 18b9a9e commit 4017d26

File tree

5 files changed

+359
-143
lines changed

5 files changed

+359
-143
lines changed

libs/soba/.storybook/main.ts

Lines changed: 36 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,33 +1,46 @@
1-
import type { StorybookConfig } from '@storybook/angular';
2-
import { resolve } from 'node:path';
3-
4-
const config: StorybookConfig = {
5-
stories: ['../**/*.mdx', '../**/*.stories.@(js|ts)'],
6-
addons: [
7-
'@storybook/addon-essentials',
8-
'storybook-addon-deep-controls',
9-
'@chromatic-com/storybook'
10-
],
11-
12-
webpackFinal: async (config) => {
13-
config.module?.rules?.push({
14-
test: /\.(glsl|vs|fs|vert|frag)$/,
15-
exclude: /node_modules/,
16-
use: ['raw-loader', 'glslify-loader'],
17-
include: resolve(__dirname, '../'),
1+
import { StorybookConfig } from '@storybook/angular';
2+
import { StorybookConfigVite } from '@storybook/builder-vite';
3+
import { UserConfig } from 'vite';
4+
5+
const config: StorybookConfig & StorybookConfigVite = {
6+
stories: ['../**/*.mdx', '../**/*.stories.@(js|ts)'],
7+
addons: ['@storybook/addon-essentials', 'storybook-addon-deep-controls', '@chromatic-com/storybook'],
8+
core: {
9+
builder: {
10+
name: '@storybook/builder-vite',
11+
options: {
12+
viteConfigPath: undefined,
13+
},
14+
},
15+
},
16+
async viteFinal(config: UserConfig) {
17+
// Merge custom configuration into the default config
18+
const { mergeConfig } = await import('vite');
19+
const { default: angular } = await import('@analogjs/vite-plugin-angular');
20+
const { nxViteTsPaths } = await import('@nx/vite/plugins/nx-tsconfig-paths.plugin');
21+
22+
return mergeConfig(config, {
23+
// Add dependencies to pre-optimization
24+
optimizeDeps: {
25+
include: [
26+
'@storybook/angular',
27+
'@storybook/angular/dist/client',
28+
'@angular/compiler',
29+
'@mdx-js/react',
30+
'@storybook/blocks',
31+
'tslib',
32+
],
33+
},
34+
plugins: [angular({ jit: true, tsconfig: './.storybook/tsconfig.json' }), nxViteTsPaths()],
1835
});
19-
20-
return config;
2136
},
2237

23-
staticDirs: ['./public', './public/cube'],
24-
25-
framework: {
38+
framework: {
2639
name: '@storybook/angular',
2740
options: {},
2841
},
2942

30-
docs: {}
43+
docs: {},
3144
};
3245

3346
export default config;

libs/soba/project.json

Lines changed: 7 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -42,31 +42,22 @@
4242
"outputs": ["{options.outputFile}"]
4343
},
4444
"storybook": {
45-
"executor": "@storybook/angular:start-storybook",
45+
"executor": "nx:run-commands",
4646
"options": {
47-
"port": 4400,
48-
"configDir": "libs/soba/.storybook",
49-
"browserTarget": "soba:build-storybook",
50-
"compodoc": false
51-
},
52-
"configurations": {
53-
"ci": {
54-
"quiet": true
55-
}
47+
"cwd": "libs/soba",
48+
"command": "storybook dev --port 4400"
5649
}
5750
},
5851
"build-storybook": {
59-
"executor": "@storybook/angular:build-storybook",
52+
"executor": "nx:run-commands",
6053
"outputs": ["{options.outputDir}"],
6154
"options": {
62-
"outputDir": "dist/storybook/soba",
63-
"configDir": "libs/soba/.storybook",
64-
"browserTarget": "soba:build-storybook",
65-
"compodoc": false
55+
"cwd": "libs/soba",
56+
"command": "storybook build --output-dir ../../dist/storybook/soba"
6657
},
6758
"configurations": {
6859
"ci": {
69-
"quiet": true
60+
"command": "storybook build --output-dir ../../dist/storybook/soba --quiet"
7061
}
7162
}
7263
},
File renamed without changes.

package.json

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,9 @@
1010
},
1111
"private": true,
1212
"devDependencies": {
13-
"@analogjs/platform": "^1.7.1",
14-
"@analogjs/vite-plugin-angular": "^1.7.1",
15-
"@analogjs/vitest-angular": "^1.7.1",
13+
"@analogjs/platform": "1.8.0-beta.2",
14+
"@analogjs/vite-plugin-angular": "1.8.0-beta.2",
15+
"@analogjs/vitest-angular": "1.8.0-beta.2",
1616
"@angular-devkit/build-angular": "18.2.0",
1717
"@angular-devkit/core": "18.2.0",
1818
"@angular-devkit/schematics": "18.2.0",
@@ -46,6 +46,7 @@
4646
"@storybook/addon-essentials": "8.2.9",
4747
"@storybook/addon-interactions": "8.2.9",
4848
"@storybook/angular": "8.2.9",
49+
"@storybook/builder-vite": "8.2.9",
4950
"@storybook/core-server": "8.2.9",
5051
"@storybook/manager-api": "^8.2.9",
5152
"@storybook/test": "8.2.9",
@@ -101,8 +102,8 @@
101102
"vitest-webgl-canvas-mock": "^1.1.0"
102103
},
103104
"dependencies": {
104-
"@analogjs/content": "^1.7.1",
105-
"@analogjs/router": "^1.7.1",
105+
"@analogjs/content": "1.8.0-beta.2",
106+
"@analogjs/router": "1.8.0-beta.2",
106107
"@angular/animations": "18.2.0",
107108
"@angular/common": "18.2.0",
108109
"@angular/compiler": "18.2.0",

0 commit comments

Comments
 (0)