New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@svitejs/svelte-preprocess-svg

Package Overview
Dependencies
Maintainers
2
Versions
5
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@svitejs/svelte-preprocess-svg

Optimize inline svg in svelte components

  • 2.0.0
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
21
increased by23.53%
Maintainers
2
Weekly downloads
 
Created
Source

@svitejs/svelte-preprocess-svg

Optimize inline svg in svelte components

Installation

npm install --save-dev @svitejs/svelte-preprocess-svg

Usage

svelte.config.js

import { sveltePreprocessSvg } from '@svitejs/svelte-preprocess-svg';
//...
export default {
	//...
	preprocess: [
		//...
		// sveltePreprocessSvg must be used AFTER other markup preprocessors like mdsvex
		sveltePreprocessSvg({
			/* options */
		})
	]
	//...
};

Documentation

options

export interface SveltePreprocessSvgOptions {
	/**
	 * Filter function to only include some files
	 *
	 * @param {PreprocessorInput} input - filename and content of the file to process
	 * @return boolean true to include the file
	 */
	include?: (input: PreprocessorInput) => boolean;

	/**
	 * Filter function to exclude some files
	 *
	 * @param {PreprocessorInput} input - filename and content of the file to process
	 * @return boolean true to exclude the file
	 */
	exclude?: (input: PreprocessorInput) => boolean;

	/**
	 * Array of transformers to apply.
	 * name: unique name of the transform - this is passed to skipTransform
	 * transform: function to manipulate svg
	 *
	 */
	transforms?: SvgTransform[];

	/**
	 * enable svgo transform, use object for custom svgo options.
	 * Without custom options it tries to load svgo config or uses defaults
	 *
	 * requires svgo to be installed as devDependency
	 */
	svgo?: boolean | object;

	/**
	 * do not wrap svg content in {@html ``}
	 */
	disableAtHtml?: boolean;

	/**
	 * skip a transform by name
	 * @param {PreprocessorInput} input - filename and content of the file to process
	 * @param {string} transform - name of the transform
	 * @param {string} svg - the svg to transform (previous transforms are already applied!)
	 */
	skipTransform?: (input: PreprocessorInput, transform: string, svg: string) => boolean;

	/**
	 * Set to true to use a simple string search instead of svelte.parse.
	 * This is faster but not fault tolerant. misaligned html comments or svg inside string literals will trip it up
	 */
	useSimpleStringParser?: boolean;
}

License

MIT

Keywords

FAQs

Package last updated on 04 Dec 2022

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc