@achmadk/vite-plugin-svgr
Advanced tools
Comparing version 1.1.0 to 1.1.1
@@ -21,13 +21,4 @@ import type { Config } from '@svgr/core'; | ||
sourceMap?: boolean; | ||
/** | ||
* @default undefined | ||
*/ | ||
svgrOptions?: Config; | ||
/** | ||
* @default undefined | ||
*/ | ||
esbuildOptions?: EsbuildTransformOptions; | ||
/** | ||
* @default undefined | ||
*/ | ||
exclude?: FilterPattern; | ||
@@ -34,0 +25,0 @@ /** |
'use strict'; | ||
const pluginutils = require('@rollup/pluginutils'); | ||
const core = require('@svgr/core'); | ||
const fs = require('fs'); | ||
@@ -10,6 +11,6 @@ const vite = require('vite'); | ||
sourceMap = false, | ||
svgrOptions = void 0, | ||
esbuildOptions = void 0, | ||
svgrOptions, | ||
esbuildOptions, | ||
include = "**/*.svg", | ||
exclude = void 0, | ||
exclude, | ||
isTypescript = false | ||
@@ -22,3 +23,2 @@ }) { | ||
if (filter(id)) { | ||
const { transform } = await import('@svgr/core'); | ||
const svgCode = await fs.promises.readFile( | ||
@@ -28,3 +28,3 @@ id.replace(/\?.*$/, ""), | ||
); | ||
const componentCode = await transform(svgCode, svgrOptions, { | ||
const componentCode = core.transform.sync(svgCode, svgrOptions, { | ||
filePath: id, | ||
@@ -35,3 +35,3 @@ caller: { | ||
}); | ||
const res = await vite.transformWithEsbuild(componentCode, id, { | ||
const res = await vite.transformWithEsbuild(`export default ${componentCode}`, id, { | ||
loader: isTypescript ? "tsx" : "jsx", | ||
@@ -38,0 +38,0 @@ ...esbuildOptions ?? {} |
{ | ||
"name": "@achmadk/vite-plugin-svgr", | ||
"private": false, | ||
"version": "1.1.0", | ||
"version": "1.1.1", | ||
"description": "Vite plugin to transform SVGs into React components", | ||
@@ -6,0 +6,0 @@ "main": "./dist/index.js", |
Sorry, the diff of this file is not supported yet
7517
122