@analogjs/storybook-angular 2.0.0-alpha.10 → 2.0.0-alpha.11

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.
Files changed (2) hide show
  1. package/README.md +53 -20
  2. package/package.json +1 -1
package/README.md CHANGED
@@ -26,7 +26,7 @@ Add the `zone.js` import to the top of the `.storybook/preview.ts` file.
26
26
 
27
27
  ```ts
28
28
  import 'zone.js';
29
- import { applicationConfig, type Preview } from '@storybook/angular';
29
+ import { applicationConfig, type Preview } from '@analogjs/storybook-angular';
30
30
  import { provideNoopAnimations } from '@angular/platform-browser/animations';
31
31
 
32
32
  const preview: Preview = {
@@ -101,17 +101,18 @@ To load shared CSS paths, configure them using `loadPaths` css option in the `vi
101
101
 
102
102
  ```ts
103
103
  import path from 'node:path';
104
+ import { UserConfig, mergeConfig } from 'vite';
104
105
 
105
- async viteFinal() {
106
- return {
106
+ export async function viteFinal(config: UserConfig) {
107
+ return mergeConfig(config, {
107
108
  css: {
108
109
  preprocessorOptions: {
109
110
  scss: {
110
- loadPaths: `${path.resolve(__dirname, '../src/lib/styles')}`
111
- }
112
- }
113
- }
114
- };
111
+ loadPaths: `${path.resolve(__dirname, '../src/lib/styles')}`,
112
+ },
113
+ },
114
+ },
115
+ });
115
116
  }
116
117
  ```
117
118
 
@@ -127,32 +128,64 @@ First, install the `vite-tsconfig-paths` package.
127
128
  npm install vite-tsconfig-paths --save-dev
128
129
  ```
129
130
 
130
- Next, add the plugin to the `plugins` array.
131
+ Next, add the plugin to the `plugins` array in the `.storybook/main.ts`.
131
132
 
132
133
  ```ts
133
134
  import viteTsConfigPaths from 'vite-tsconfig-paths';
135
+ import { UserConfig, mergeConfig } from 'vite';
134
136
 
135
- async viteFinal() {
136
- return {
137
- plugins: [
138
- viteTsConfigPaths()
139
- ],
140
- };
137
+ export async function viteFinal(config: UserConfig) {
138
+ return mergeConfig(config, {
139
+ plugins: [viteTsConfigPaths()],
140
+ });
141
141
  }
142
142
  ```
143
143
 
144
144
  ### With Nx
145
145
 
146
- For Nx workspaces, import and use the `nxViteTsPaths` plugin from the `@nx/vite` package.
146
+ 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`.
147
147
 
148
148
  ```ts
149
149
  import { nxViteTsPaths } from '@nx/vite/plugins/nx-tsconfig-paths.plugin';
150
+ import { UserConfig, mergeConfig } from 'vite';
151
+
152
+ export async function viteFinal(config: UserConfig) {
153
+ return mergeConfig(config, {
154
+ plugins: [nxViteTsPaths()],
155
+ });
156
+ }
157
+ ```
158
+
159
+ ## Using File Replacements
150
160
 
151
- async viteFinal(config: UserConfig) {
152
- return {
161
+ You can also use the `replaceFiles()` plugin from Nx to replace files during your build.
162
+
163
+ Import the plugin and set it up:
164
+
165
+ ```ts
166
+ import { replaceFiles } from '@nx/vite/plugins/rollup-replace-files.plugin';
167
+ import { UserConfig, mergeConfig } from 'vite';
168
+
169
+ export async function viteFinal(config: UserConfig) {
170
+ return mergeConfig(config, {
153
171
  plugins: [
154
- nxViteTsPaths()
172
+ replaceFiles([
173
+ {
174
+ replace: './src/one.ts',
175
+ with: './src/two.ts',
176
+ },
177
+ ]),
155
178
  ],
156
- };
179
+ });
180
+ }
181
+ ```
182
+
183
+ Adding the replacement files to `files` array in the `tsconfig.app.json` may also be necessary.
184
+
185
+ ```json
186
+ {
187
+ "extends": "./tsconfig.json",
188
+ // other config
189
+ "files": ["src/main.ts", "src/main.server.ts", "src/two.ts"]
157
190
  }
158
191
  ```
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@analogjs/storybook-angular",
3
- "version": "2.0.0-alpha.10",
3
+ "version": "2.0.0-alpha.11",
4
4
  "description": "Storybook Integration for Angular & Vite",
5
5
  "keywords": [
6
6
  "storybook",