vite-plugin-svgr 1.0.1 → 1.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/lib/index.js +1 -0
  2. package/package.json +2 -3
package/lib/index.js CHANGED
@@ -32,6 +32,7 @@ module.exports = function svgrPlugin({ svgrOptions, esbuildOptions, } = {}) {
32
32
  const svgCode = await fs_1.default.promises.readFile(id, 'utf8');
33
33
  const componentCode = await convert(svgCode, svgrOptions, {
34
34
  componentName: 'ReactComponent',
35
+ filePath: id,
35
36
  }).then((res) => {
36
37
  return res.replace('export default ReactComponent', `export { ReactComponent }`);
37
38
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "vite-plugin-svgr",
3
- "version": "1.0.1",
3
+ "version": "1.1.0",
4
4
  "description": "Vite plugin to transform SVGs into React components",
5
5
  "main": "lib/index.js",
6
6
  "repository": "pd4d10/vite-plugin-svgr",
@@ -27,8 +27,7 @@
27
27
  },
28
28
  "scripts": {
29
29
  "dev": "tsc --watch",
30
- "build": "tsc",
31
- "prepublish": "npm run build"
30
+ "build": "tsc"
32
31
  },
33
32
  "readme": "# vite-plugin-svgr\n\n[![npm](https://img.shields.io/npm/v/vite-plugin-svgr.svg)](https://www.npmjs.com/package/vite-plugin-svgr)\n\nVite plugin to transform SVGs into React components. Uses [svgr](https://github.com/gregberge/svgr) under the hood.\n\n## Usage\n\n```js\n// vite.config.js\nimport svgrPlugin from 'vite-plugin-svgr'\n\nexport default {\n // ...\n plugins: [\n svgrPlugin({\n svgrOptions: {\n icon: true,\n // ...svgr options (https://react-svgr.com/docs/options/)\n },\n }),\n ],\n}\n```\n\nThen SVG files can be imported as React components, just like [create-react-app](https://create-react-app.dev/docs/adding-images-fonts-and-files#adding-svgs) does:\n\n```js\nimport { ReactComponent as Logo } from './logo.svg'\n```\n\nIf you are using TypeScript, `vite-plugin-svgr/client` can be added to `tsconfig.json`:\n\n```json\n{\n // ...\n \"compilerOptions\": {\n // ...\n \"types\": [\"vite-plugin-svgr/client\"]\n }\n}\n```\n\n## License\n\nMIT\n"
34
33
  }