GithubHelp home page GithubHelp logo

aeirola / react-native-svg-asset-plugin Goto Github PK

View Code? Open in Web Editor NEW
68.0 4.0 9.0 2.35 MB

Asset plugin for importing SVG images in React Native

Home Page: https://www.npmjs.com/package/react-native-svg-asset-plugin

License: MIT License

JavaScript 59.49% Java 14.12% Objective-C 9.98% Ruby 12.06% Starlark 4.35%
react-native svg

react-native-svg-asset-plugin's People

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

react-native-svg-asset-plugin's Issues

Colons are not allowed in file names on Windows

Using a colon in the file names created here:
const outputName = ${assetData.name}:${assetData.hash};
causes issues on Windows, the PNG files are not created (instead you get empty files in the cache folder).

Cache directories not cleaned up

The plugin caches generated PNG images under .png-cache directories adjacent to any imported SVG files. Due to metro bundler caching, the plugin retains all old versions of SVG images in the caches, meaning that the caches only grow as more changes are made to the SVG files. This can cause unnecessary disk space usage.

Metro idles after bundling

The command yarn react-native bundle --platform android --entry-file index.ts --bundle-output out idles for at least a few minutes after it finished.

I found out that the following lines are responsible for this: https://github.com/aeirola/react-native-svg-asset-plugin/blob/master/src/cache.js#L63-L67

This was introduced here: https://github.com/aeirola/react-native-svg-asset-plugin/pull/49/files

When building in release mode there should be no cleanup task scheduled.

Build on Mac not successfull

First, thanks for your library!
When building our app for iPhone in a Mac environment, the images are not rendered (the build doesn't cancel though).

The console gives the following output:

bundle: Writing bundle output to: /[...]/Build/Intermediates.noindex/ArchiveIntermediates/Integreat/BuildProductsPath/Release-iphoneos/Integreat.app/main.jsbundle
bundle: Done writing bundle output

Input buffer has corrupt header: glib: SVG has no elements



Error: Input buffer has corrupt header: glib: SVG has no elements



+ [[ false != true ]]
+ [[ ! -f /[...]/Build/Intermediates.noindex/ArchiveIntermediates/Integreat/BuildProductsPath/Release-iphoneos/Integreat.app/main.jsbundle ]]

A similar library like yours uses a workaround for this issue:
aeirola/react-native-icon-builder@c1e8262

This issue might also be related to lovell/sharp#1593.

I hope you can fix this.

Edit: I just noticed this other library is authored by you as well :D Do you think this is the same issue here?

Edit2: I just saw that you already released something 3 hours ago for this :O I'm checking this out โค๏ธ

Edit3: It does already work, thanks ๐Ÿ‘

Expo support?

Stumbled upon this project,
was wondering if it works with Expo.
Followed the instructions, but haven't been able to get it to run in Expo yet.

Feature request: configure ignore folder

Looking at the current configuration opens it's not possible to configure a folder from which all required SVG files will be ignored. This prevents me from using this plugin in conjunction with react-native-svg.

Is there maybe any way to achieve this using metro configuration alone?
Thanks.

Unable to open 'file' for writing

Error message: error: bundling failed: Error: vips__file_open_write: unable to open file "/path-to-file/.png-cache/file.png" for writing
unix error: Invalid argument

I couldn't use your plugin because of this error. Somehow, the plugin wasn't able to save the file.

Although I couldn't find any code for folder creation, I saw that the plugin was able to create .png-cache folder during the transformation. I found this issue that could help solving this problem, but I do know that the folder was created.

PNG compression

It would be nice if the generated pngs could be compressed, for example by using pngquant, to reduce the file size of the pngs.
It would be cool if this could be configurable.

Can this plugin be enabled only for Android/AndroidTV platform?

Hi, I was wondering if this plugin could be enabled only in case of Android/AndroidTV platform? Maybe this can be done in metro.config.js file?

I am using this plugin because SVG assets are not supported directly in Android, but I wouldn't like to change how SVGs are used on other platforms.

Any help would be appreciated.

Changes to SVGs not always reflected in application

Occasionally changes to SVG files do not always show up in the application. This seems to occur on changes to the files, which are later reverted. Changes which produce new images are shown properly in the application.

This probably has something to do with how Metro caches the assets.

iOS PDF output

iOS / Xcode supports vector graphics in PDF format. In theory it would be possible to generate PDFs from source SVG images, in addition to the PNG images already generated. This would also require some way of then passing the PDF files to the image component in React Native. There is support for Hybrid app resources, but not entirely sure how it would work.

There already seems to exist https://github.com/alafr/SVG-to-PDFKit which is able to convert SVG files to PDF, so the heavy lifting is already done in some part.

unable to use pngs directly?

I am in the scenario where I have some svg images and some jpg/png images.

When using this plugin all the svg are converted and loaded correctly, but when trying to use the png it does not work and shows a blank image.

Is it supposed to be like this?

Support uri?

Hye, the projects look interesting, I have a question.. does this package support svg that is coming from uri? such

https://restcountries.eu/data/mys.svg

Thanks!

Android VectorDrawable output

Android supports its own vector graphic format called VectorDrawable. It could be convenient if this library would also support generating vector drwable resources instead of / in addition to PNG images. VectorDrawables seem to be a subset of SVG though, so this would require some mechanism for identifying lossy conversions and warn about them or fall back to PNG images.

Also not entirely sure how to properly pass the native image resources to React Native. There is some support for Hybrid app resources in React Native. But not sure though how those should be generated and passed by an asset plugin.

There seems to already exist a library for doing the conversion at https://github.com/Ashung/svg2vectordrawable. Probably wouldn't hurt to try it out as an experimental feature.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.