add configuration options
This commit is contained in:
		
							parent
							
								
									920f088ff8
								
							
						
					
					
						commit
						4f2d2e5863
					
				
					 1 changed files with 11 additions and 8 deletions
				
			
		
							
								
								
									
										19
									
								
								src/index.js
									
										
									
									
									
								
							
							
						
						
									
										19
									
								
								src/index.js
									
										
									
									
									
								
							|  | @ -1,14 +1,17 @@ | ||||||
| import fs from 'node:fs/promises' | import fs from 'node:fs/promises' | ||||||
| 
 | 
 | ||||||
| export const wgsl = () => ({ | export const wgsl = ({ filterWith, filterExtension }) => ({ | ||||||
|     name: 'esbuild-plugin-wgsl', |   name: 'esbuild-plugin-wgsl', | ||||||
|     setup(build) { |   setup(build) { | ||||||
|         build.onLoad({ filter: /\.wgsl$/ }, async args => { |     const filter = filterExtension || true ? /\.wgsl$/ : /.*/ | ||||||
|             const contents = await fs.readFile(args.path, 'utf8') |     build.onLoad({ filter }, async args => { | ||||||
|  |       if (!filterWith || args.filter.with === 'wgsl') { | ||||||
|  |         const contents = await fs.readFile(args.path, 'utf8') | ||||||
| 
 | 
 | ||||||
|             return { contents } |         return { contents, loader: 'text' } | ||||||
|         }) |       } | ||||||
|     } |     }) | ||||||
|  |   } | ||||||
| }) | }) | ||||||
| 
 | 
 | ||||||
| export default wgsl | export default wgsl | ||||||
|  |  | ||||||
		Loading…
	
	Add table
		
		Reference in a new issue