rollup-plugin-svelte-svg
Version:
Import SVG images as Svelte Components
32 lines • 3.72 kB
JSON
{
"name": "rollup-plugin-svelte-svg",
"version": "1.0.0-beta.6",
"description": "Import SVG images as Svelte Components",
"main": "index.js",
"dependencies": {
"rollup-pluginutils": "^2.8.2",
"svgo": "^2.3.1"
},
"peerDependencies": {
"svelte": "*"
},
"repository": {
"type": "git",
"url": "git+https://github.com/codefeathers/rollup-plugin-svelte-svg.git"
},
"keywords": [
"rollup-plugin",
"vite-plugin",
"svg",
"images",
"svelte",
"svelte-component"
],
"author": "MKRhere <@MKRhere> (https://mkr.pw)",
"license": "MIT",
"bugs": {
"url": "https://github.com/codefeathers/rollup-plugin-svelte-svg/issues"
},
"homepage": "https://github.com/codefeathers/rollup-plugin-svelte-svg#readme",
"readme": "# rollup-plugin-svelte-svg\n\nImport SVG files as Svelte Components\n\n> Note: `rollup-plugin-svelte-svg` was rewritten from scratch recently, and no longer exposes Svelte options `({ dev, generate })` since we now delegate compilation to the Svelte plugin that's loaded after us. You should remove these options since they have no effect.\n>\n> This is a nonbreaking change for most users, however if you do face a problem, raise an issue.\n\n## Contents\n- [Installation](#installation)\n- [Usage](#usage)\n - [Svelte](#svelte)\n - [Sapper](#sapper)\n - [Vite](#vite)\n- [Credits](#credits)\n- [License](#license)\n\n## Installation\n\n```bash\n# using npm\nnpm i -D rollup-plugin-svelte-svg\n\n# using yarn\nyarn add -D rollup-plugin-svelte-svg\n\n# using pnpm\npnpm i -D rollup-plugin-svelte-svg\n```\n\n## Usage\n\nSimply call `svelteSVG` before `svelte` in your rollup config.\n\n### Svelte\n```js\n// rollup.config.js\nimport { svelteSVG } from \"rollup-plugin-svelte-svg\";\n\nexport default {\n entry: \"src/input.js\",\n dest: \"dist/output.js\",\n plugins: [\n svelteSVG({\n // optional SVGO options\n // pass empty object to enable defaults\n svgo: {}\n }),\n ],\n ...\n}\n```\n\n### Sapper\n```js\n// rollup.config.js\nimport { svelteSVG } from \"rollup-plugin-svelte-svg\";\n\nexport default {\n client: {\n plugins: [\n svelteSVG({\n // optional SVGO options\n // pass empty object to enable defaults\n svgo: {},\n }),\n ],\n ...\n },\n server: {\n plugins: [\n svelteSVG({\n // optional SVGO options\n // pass empty object to enable defaults\n svgo: {}\n }),\n ],\n ...\n },\n}\n```\n\n### Vite\n\n```js\n// vite.config.js\nimport { defineConfig } from \"vite\"; \nimport { svelteSVG } from \"rollup-plugin-svelte-svg\";\n\nexport default defineConfig({\n ...\n plugins: [\n svelteSVG({\n // optional SVGO options\n // pass empty object to enable defaults\n svgo: {},\n // vite-specific\n // https://vitejs.dev/guide/api-plugin.html#plugin-ordering\n // enforce: 'pre' | 'post'\n enforce: \"pre\",\n }),\n ...\n ],\n});\n```\n\nYou can then import svg in your JS thusly:\n\n```html\n<script>\n\timport Logo from \"./logo.svg\";\n</script>\n\n<Logo width=20 />\n```\n\n## Credits\n\n* This plugin was originally forked from [antony/rollup-plugin-svg](https://github.com/antony/rollup-plugin-svg), but has been rewritten since.\n\n* [@featherbear's fork](https://github.com/featherbear/rollup-plugin-svelte-svg) and [metafy-gg's fork](https://github.com/metafy-gg/vite-plugin-svelte-svg) inspired svgo optimisation and vite support.\n\n## License\n\nMIT\n"
}