| 
									
										
										
										
											2025-08-14 13:12:39 +02:00
										 |  |  | import {StorybookConfig} from '@storybook/angular'; | 
					
						
							|  |  |  | import * as path from 'path'; | 
					
						
							| 
									
										
										
										
											2025-08-14 12:18:20 +02:00
										 |  |  | 
 | 
					
						
							|  |  |  | const config: StorybookConfig = { | 
					
						
							| 
									
										
										
										
											2025-08-14 13:12:39 +02:00
										 |  |  |   stories: ['../src/**/*.stories.@(js|jsx|ts|tsx|mdx)'], | 
					
						
							| 
									
										
										
										
											2025-08-14 12:18:20 +02:00
										 |  |  |   addons: [ | 
					
						
							|  |  |  |     '@storybook/addon-links', | 
					
						
							| 
									
										
										
										
											2025-08-14 13:12:39 +02:00
										 |  |  |     '@storybook/addon-docs', | 
					
						
							| 
									
										
										
										
											2025-08-19 10:58:54 +02:00
										 |  |  |     // '@storybook/addon-viewport',
 | 
					
						
							|  |  |  |     // Removed deprecated addons:
 | 
					
						
							|  |  |  |     // '@storybook/addon-backgrounds' - no longer exists in Storybook 9.0+
 | 
					
						
							|  |  |  |     // '@storybook/addon-controls' - no longer exists in Storybook 9.0+
 | 
					
						
							| 
									
										
										
										
											2025-08-14 13:12:39 +02:00
										 |  |  |     // ... autres addons
 | 
					
						
							| 
									
										
										
										
											2025-08-14 12:18:20 +02:00
										 |  |  |   ], | 
					
						
							|  |  |  |   framework: { | 
					
						
							|  |  |  |     name: '@storybook/angular', | 
					
						
							| 
									
										
										
										
											2025-08-14 13:12:39 +02:00
										 |  |  |     options: {} | 
					
						
							| 
									
										
										
										
											2025-08-14 12:18:20 +02:00
										 |  |  |   }, | 
					
						
							|  |  |  |   webpackFinal: async (config) => { | 
					
						
							|  |  |  |     if (config.module?.rules) { | 
					
						
							| 
									
										
										
										
											2025-08-14 13:12:39 +02:00
										 |  |  |       // Support MDX
 | 
					
						
							| 
									
										
										
										
											2025-08-14 12:18:20 +02:00
										 |  |  |       config.module.rules.push({ | 
					
						
							|  |  |  |         test: /\.mdx?$/, | 
					
						
							| 
									
										
										
										
											2025-08-14 13:12:39 +02:00
										 |  |  |         use: [{loader: require.resolve('@mdx-js/loader')}], | 
					
						
							| 
									
										
										
										
											2025-08-14 12:18:20 +02:00
										 |  |  |       }); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2025-08-14 13:12:39 +02:00
										 |  |  |       // Support fonts amélioré
 | 
					
						
							| 
									
										
										
										
											2025-08-14 12:18:20 +02:00
										 |  |  |       config.module.rules.push({ | 
					
						
							|  |  |  |         test: /\.(woff|woff2|eot|ttf|otf)$/, | 
					
						
							| 
									
										
										
										
											2025-08-14 13:12:39 +02:00
										 |  |  |         type: 'asset/resource', | 
					
						
							|  |  |  |         generator: {filename: 'fonts/[name].[contenthash][ext]'}, | 
					
						
							| 
									
										
										
										
											2025-08-14 12:18:20 +02:00
										 |  |  |       }); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2025-08-18 18:14:22 +02:00
										 |  |  |       // Support for remixicon font files specifically
 | 
					
						
							|  |  |  |       config.module.rules.push({ | 
					
						
							|  |  |  |         test: /remixicon.*\.(woff|woff2|eot|ttf|svg)$/, | 
					
						
							|  |  |  |         type: 'asset/resource', | 
					
						
							|  |  |  |         generator: {filename: 'fonts/[name].[contenthash][ext]'}, | 
					
						
							|  |  |  |       }); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |       // Add CSS loader rule to handle @font-face declarations
 | 
					
						
							|  |  |  |       config.module.rules.push({ | 
					
						
							|  |  |  |         test: /\.css$/, | 
					
						
							|  |  |  |         use: [ | 
					
						
							|  |  |  |           'style-loader', | 
					
						
							|  |  |  |           { | 
					
						
							|  |  |  |             loader: 'css-loader', | 
					
						
							|  |  |  |             options: { | 
					
						
							|  |  |  |               url: true | 
					
						
							|  |  |  |             } | 
					
						
							|  |  |  |           } | 
					
						
							|  |  |  |         ] | 
					
						
							|  |  |  |       }); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2025-08-14 13:12:39 +02:00
										 |  |  |       // NOUVELLE SOLUTION : Configurer css-loader pour gérer les URLs
 | 
					
						
							|  |  |  |       const scssRules = config.module.rules.filter(rule => { | 
					
						
							|  |  |  |         if (rule && typeof rule === 'object' && 'test' in rule && rule.test) { | 
					
						
							|  |  |  |           const testString = rule.test.toString(); | 
					
						
							|  |  |  |           return testString.includes('scss') || testString.includes('sass'); | 
					
						
							|  |  |  |         } | 
					
						
							|  |  |  |         return false; | 
					
						
							|  |  |  |       }); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |       scssRules.forEach(rule => { | 
					
						
							|  |  |  |         if (rule && typeof rule === 'object' && 'use' in rule && Array.isArray(rule.use)) { | 
					
						
							|  |  |  |           const cssLoaderIndex = rule.use.findIndex((loader: any) => { | 
					
						
							|  |  |  |             if (typeof loader === 'string') { | 
					
						
							|  |  |  |               return loader.includes('css-loader'); | 
					
						
							|  |  |  |             } | 
					
						
							|  |  |  |             return loader && loader.loader && loader.loader.includes('css-loader'); | 
					
						
							|  |  |  |           }); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |           if (cssLoaderIndex !== -1) { | 
					
						
							|  |  |  |             const cssLoader = rule.use[cssLoaderIndex] as any; | 
					
						
							|  |  |  |             if (typeof cssLoader === 'object' && cssLoader.options) { | 
					
						
							|  |  |  |               cssLoader.options.url = { | 
					
						
							|  |  |  |                 filter: (url: string) => { | 
					
						
							|  |  |  |                   // Skip problematic URLs with complex relative paths
 | 
					
						
							|  |  |  |                   if (url.includes('../../../../my-workspace/')) { | 
					
						
							|  |  |  |                     return false; | 
					
						
							|  |  |  |                   } | 
					
						
							|  |  |  |                   return true; | 
					
						
							|  |  |  |                 } | 
					
						
							|  |  |  |               }; | 
					
						
							|  |  |  |             } | 
					
						
							|  |  |  |           } | 
					
						
							|  |  |  |         } | 
					
						
							|  |  |  |       }); | 
					
						
							| 
									
										
										
										
											2025-08-14 12:18:20 +02:00
										 |  |  |     } | 
					
						
							| 
									
										
										
										
											2025-08-14 13:12:39 +02:00
										 |  |  | 
 | 
					
						
							|  |  |  |     // Alias
 | 
					
						
							|  |  |  |     if (!config.resolve) config.resolve = {}; | 
					
						
							|  |  |  |     if (!config.resolve.alias) config.resolve.alias = {}; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     config.resolve.alias['~src'] = path.resolve(__dirname, '../src'); | 
					
						
							| 
									
										
										
										
											2025-08-19 10:58:54 +02:00
										 |  |  |     config.resolve.alias['sae-lib'] = path.resolve(__dirname, '../../my-workspace/projects/sae-lib'); | 
					
						
							| 
									
										
										
										
											2025-08-14 13:12:39 +02:00
										 |  |  | 
 | 
					
						
							|  |  |  |     // Ajouter un alias pour remixicon
 | 
					
						
							|  |  |  |     config.resolve.alias['remixicon'] = path.resolve(__dirname, '../node_modules/remixicon'); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     // Modules resolution
 | 
					
						
							|  |  |  |     if (!config.resolve.modules) config.resolve.modules = []; | 
					
						
							|  |  |  |     config.resolve.modules.push(path.resolve(__dirname, '../node_modules')); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     config.resolve.symlinks = true; | 
					
						
							| 
									
										
										
										
											2025-08-14 12:18:20 +02:00
										 |  |  | 
 | 
					
						
							|  |  |  |     return config; | 
					
						
							| 
									
										
										
										
											2025-08-14 13:12:39 +02:00
										 |  |  |   } | 
					
						
							| 
									
										
										
										
											2025-08-14 12:18:20 +02:00
										 |  |  | }; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | export default config; |