mirror of
				https://github.com/Unleash/unleash.git
				synced 2025-10-27 11:02:16 +01:00 
			
		
		
		
	chore: support css modules in storybook
This commit is contained in:
		
							parent
							
								
									4a795966d1
								
							
						
					
					
						commit
						790bd4da0f
					
				| @ -1,5 +1,3 @@ | ||||
| const path = require('path'); | ||||
| 
 | ||||
| module.exports = { | ||||
|     stories: [ | ||||
|         '../src/**/*.stories.mdx', | ||||
| @ -19,7 +17,48 @@ module.exports = { | ||||
|         }, | ||||
|     ], | ||||
|     webpackFinal: async (config) => { | ||||
|         config.resolve.alias['@site'] = path.resolve(__dirname, '../'); | ||||
|         return config; | ||||
|         const path = require('path'); | ||||
| 
 | ||||
|         config.resolve.alias = { | ||||
|             ...config.resolve.alias, | ||||
|             '@site': path.resolve(__dirname, '../'), | ||||
|         }; | ||||
| 
 | ||||
|         const rules = config.module.rules.map((rule) => { | ||||
|             if (rule.test.toString() !== '/\\.css$/') { | ||||
|                 return rule; | ||||
|             } | ||||
| 
 | ||||
|             const use = rule.use.map((u) => { | ||||
|                 const { loader } = u; | ||||
| 
 | ||||
|                 if (!loader || !loader.includes('/css-loader/')) { | ||||
|                     return u; | ||||
|                 } | ||||
| 
 | ||||
|                 const options = { | ||||
|                     ...u.options, | ||||
|                     modules: true, | ||||
|                 }; | ||||
| 
 | ||||
|                 return { | ||||
|                     ...u, | ||||
|                     options, | ||||
|                 }; | ||||
|             }); | ||||
| 
 | ||||
|             return { | ||||
|                 ...rule, | ||||
|                 use, | ||||
|             }; | ||||
|         }); | ||||
| 
 | ||||
|         return { | ||||
|             ...config, | ||||
|             module: { | ||||
|                 ...config.module, | ||||
|                 rules, | ||||
|             }, | ||||
|         }; | ||||
|     }, | ||||
| }; | ||||
|  | ||||
		Loading…
	
		Reference in New Issue
	
	Block a user