mirror of
				https://github.com/mastermindzh/rickvanlieshout.com
				synced 2025-11-04 02:29:46 +01:00 
			
		
		
		
	
		
			
				
	
	
		
			26 lines
		
	
	
		
			636 B
		
	
	
	
		
			TypeScript
		
	
	
	
	
	
			
		
		
	
	
			26 lines
		
	
	
		
			636 B
		
	
	
	
		
			TypeScript
		
	
	
	
	
	
import path from "path";
 | 
						|
 | 
						|
import { CreateWebpackConfigArgs } from "gatsby";
 | 
						|
import { CompilerOptions } from "typescript";
 | 
						|
 | 
						|
import { compilerOptions } from "../../tsconfig.json";
 | 
						|
 | 
						|
const onCreateWebpackConfig = (
 | 
						|
  (options: Pick<CompilerOptions, "paths">) =>
 | 
						|
  ({ actions }: CreateWebpackConfigArgs) => {
 | 
						|
    actions.setWebpackConfig({
 | 
						|
      resolve: {
 | 
						|
        alias: Object.entries(options.paths || []).reduce(
 | 
						|
          (aliases, [name, [target]]) => ({
 | 
						|
            ...aliases,
 | 
						|
            [name]: path.resolve(target),
 | 
						|
          }),
 | 
						|
          {},
 | 
						|
        ),
 | 
						|
      },
 | 
						|
    });
 | 
						|
  }
 | 
						|
)(compilerOptions);
 | 
						|
 | 
						|
export { onCreateWebpackConfig };
 |