summaryrefslogtreecommitdiff
path: root/octicon-svg-loader.ts
blob: a01eb9a98e7a1dbc89aca03e44b57716b8ae4ea5 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
import path from 'path';
import webpack from 'webpack';

export default function (this: webpack.loader.LoaderContext, source: string): string {
	const iconName = path.basename(this.resourcePath, path.extname(this.resourcePath));
	const svgWithClass = source.replace(
		'<svg',
		`<svg class="octicon octicon-${iconName}"`
	);
	return `
	import React from 'dom-chef';
	export default () => ${svgWithClass}`;
}