How to use the svg-sprite-loader/lib/utils/generate-import.js function in svg-sprite-loader

To help you get started, we’ve selected a few svg-sprite-loader examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github zuzucheFE / guido / lib / utils / svgSpriteRuntimeGenerator.js View on Github external
const symbolModuleAbsPath = path.isAbsolute(symbolModule)
			? symbolModule
			: path.join(context, symbolModule);

		const spriteModuleImport = stringifyRequest(
			loaderContext,
			spriteModuleAbsPath
		);
		const symbolModuleImport = stringifyRequest(
			loaderContext,
			symbolModuleAbsPath
		);

		runtime = [
			generateImport('SpriteSymbol', symbolModuleImport, esModule),
			generateImport('sprite', spriteModuleImport, esModule),
			generateImport('React', 'react', esModule),

			`let symbol = new SpriteSymbol(${stringifySymbol(symbol)})`,
			'sprite.add(symbol)',
		];

		let rcDisplayName = `${pascalCase(symbolId)}SpriteSymbolComponent`;
		runtime.push(
			`export default function ${rcDisplayName}(props) {
                let newProps = {};
                if (props.className !== undefined) {
                    newProps.className = props.className;
                }
                for (let i in props) {
                    if (i !== 'className' && Object.prototype.hasOwnProperty.call(props, i)) {
                        newProps[i] = props[i];
github zuzucheFE / guido / lib / config / svg-sprite-runtime-generator.js View on Github external
const data = `{
      id: ${stringify(symbolId)},
      viewBox: ${stringify(symbol.viewBox)},
      url: ${publicPath} + ${stringify(spritePlaceholder)},
      width: ${width},
      height: ${height}
    }`;

        runtime = generateExport(data, esModule);
    } else {
        const spriteModuleImport = stringifyRequest({ context }, spriteModule);
        const symbolModuleImport = stringifyRequest({ context }, symbolModule);

        runtime = [
            generateImport('SpriteSymbol', symbolModuleImport, esModule),
            generateImport('sprite', spriteModuleImport, esModule),
            generateImport('React', 'react', esModule),

            `let symbol = new SpriteSymbol(${stringifySymbol(symbol)})`,
            'sprite.add(symbol)',
        ];

        let rcDisplayName = `${pascalCase(symbolId)}SpriteSymbolComponent`;
        runtime.push(
            `export default function ${rcDisplayName}(props) {
                let newProps = {};
                if (props.className !== undefined) {
                    newProps.className = props.className;
                }
                for (let i in props) {
                    if (i !== 'className' && Object.prototype.hasOwnProperty.call(props, i)) {
                        newProps[i] = props[i];
github zuzucheFE / guido / lib / utils / svgSpriteRuntimeGenerator.js View on Github external
: path.join(context, spriteModule);
		const symbolModuleAbsPath = path.isAbsolute(symbolModule)
			? symbolModule
			: path.join(context, symbolModule);

		const spriteModuleImport = stringifyRequest(
			loaderContext,
			spriteModuleAbsPath
		);
		const symbolModuleImport = stringifyRequest(
			loaderContext,
			symbolModuleAbsPath
		);

		runtime = [
			generateImport('SpriteSymbol', symbolModuleImport, esModule),
			generateImport('sprite', spriteModuleImport, esModule),
			generateImport('React', 'react', esModule),

			`let symbol = new SpriteSymbol(${stringifySymbol(symbol)})`,
			'sprite.add(symbol)',
		];

		let rcDisplayName = `${pascalCase(symbolId)}SpriteSymbolComponent`;
		runtime.push(
			`export default function ${rcDisplayName}(props) {
                let newProps = {};
                if (props.className !== undefined) {
                    newProps.className = props.className;
                }
                for (let i in props) {
                    if (i !== 'className' && Object.prototype.hasOwnProperty.call(props, i)) {
github zuzucheFE / guido / lib / utils / svgSpriteRuntimeGenerator.js View on Github external
? symbolModule
			: path.join(context, symbolModule);

		const spriteModuleImport = stringifyRequest(
			loaderContext,
			spriteModuleAbsPath
		);
		const symbolModuleImport = stringifyRequest(
			loaderContext,
			symbolModuleAbsPath
		);

		runtime = [
			generateImport('SpriteSymbol', symbolModuleImport, esModule),
			generateImport('sprite', spriteModuleImport, esModule),
			generateImport('React', 'react', esModule),

			`let symbol = new SpriteSymbol(${stringifySymbol(symbol)})`,
			'sprite.add(symbol)',
		];

		let rcDisplayName = `${pascalCase(symbolId)}SpriteSymbolComponent`;
		runtime.push(
			`export default function ${rcDisplayName}(props) {
                let newProps = {};
                if (props.className !== undefined) {
                    newProps.className = props.className;
                }
                for (let i in props) {
                    if (i !== 'className' && Object.prototype.hasOwnProperty.call(props, i)) {
                        newProps[i] = props[i];
                    }
github zuzucheFE / guido / lib / utils / svgSpriteRuntimeGeneratorNotReact.js View on Github external
: path.join(context, spriteModule);
		const symbolModuleAbsPath = path.isAbsolute(symbolModule)
			? symbolModule
			: path.join(context, symbolModule);

		const spriteModuleImport = stringifyRequest(
			loaderContext,
			spriteModuleAbsPath
		);
		const symbolModuleImport = stringifyRequest(
			loaderContext,
			symbolModuleAbsPath
		);

		runtime = [
			generateImport('SpriteSymbol', symbolModuleImport, esModule),
			generateImport('sprite', spriteModuleImport, esModule),

			`let symbol = new SpriteSymbol(${stringifySymbol(symbol)})`,
			'sprite.add(symbol)',
		];

		if (runtimeCompat) {
			runtime.push(`export let symbolData = "#${symbolId}"`);
		} else {
			runtime.push(`export let symbolData = symbol`);
		}

		runtime = runtime.join(';\n');
	}

	return runtime;
github zuzucheFE / guido / lib / config / svg-sprite-runtime-generator.js View on Github external
const data = `{
      id: ${stringify(symbolId)},
      viewBox: ${stringify(symbol.viewBox)},
      url: ${publicPath} + ${stringify(spritePlaceholder)},
      width: ${width},
      height: ${height}
    }`;

        runtime = generateExport(data, esModule);
    } else {
        const spriteModuleImport = stringifyRequest({ context }, spriteModule);
        const symbolModuleImport = stringifyRequest({ context }, symbolModule);

        runtime = [
            generateImport('SpriteSymbol', symbolModuleImport, esModule),
            generateImport('sprite', spriteModuleImport, esModule),
            generateImport('React', 'react', esModule),

            `let symbol = new SpriteSymbol(${stringifySymbol(symbol)})`,
            'sprite.add(symbol)',
        ];

        let rcDisplayName = `${pascalCase(symbolId)}SpriteSymbolComponent`;
        runtime.push(
            `export default function ${rcDisplayName}(props) {
                let newProps = {};
                if (props.className !== undefined) {
                    newProps.className = props.className;
                }
                for (let i in props) {
                    if (i !== 'className' && Object.prototype.hasOwnProperty.call(props, i)) {
github zuzucheFE / guido / lib / utils / svgSpriteRuntimeGeneratorNotReact.js View on Github external
const symbolModuleAbsPath = path.isAbsolute(symbolModule)
			? symbolModule
			: path.join(context, symbolModule);

		const spriteModuleImport = stringifyRequest(
			loaderContext,
			spriteModuleAbsPath
		);
		const symbolModuleImport = stringifyRequest(
			loaderContext,
			symbolModuleAbsPath
		);

		runtime = [
			generateImport('SpriteSymbol', symbolModuleImport, esModule),
			generateImport('sprite', spriteModuleImport, esModule),

			`let symbol = new SpriteSymbol(${stringifySymbol(symbol)})`,
			'sprite.add(symbol)',
		];

		if (runtimeCompat) {
			runtime.push(`export let symbolData = "#${symbolId}"`);
		} else {
			runtime.push(`export let symbolData = symbol`);
		}

		runtime = runtime.join(';\n');
	}

	return runtime;
};
github zuzucheFE / guido / lib / config / svg-sprite-runtime-generator.js View on Github external
id: ${stringify(symbolId)},
      viewBox: ${stringify(symbol.viewBox)},
      url: ${publicPath} + ${stringify(spritePlaceholder)},
      width: ${width},
      height: ${height}
    }`;

        runtime = generateExport(data, esModule);
    } else {
        const spriteModuleImport = stringifyRequest({ context }, spriteModule);
        const symbolModuleImport = stringifyRequest({ context }, symbolModule);

        runtime = [
            generateImport('SpriteSymbol', symbolModuleImport, esModule),
            generateImport('sprite', spriteModuleImport, esModule),
            generateImport('React', 'react', esModule),

            `let symbol = new SpriteSymbol(${stringifySymbol(symbol)})`,
            'sprite.add(symbol)',
        ];

        let rcDisplayName = `${pascalCase(symbolId)}SpriteSymbolComponent`;
        runtime.push(
            `export default function ${rcDisplayName}(props) {
                let newProps = {};
                if (props.className !== undefined) {
                    newProps.className = props.className;
                }
                for (let i in props) {
                    if (i !== 'className' && Object.prototype.hasOwnProperty.call(props, i)) {
                        newProps[i] = props[i];
                    }