svgr
rollup-plugin-visualizer
Our great sponsors
svgr | rollup-plugin-visualizer | |
---|---|---|
26 | 2 | |
9,327 | 1,157 | |
- | - | |
8.3 | 7.1 | |
29 days ago | about 1 month ago | |
TypeScript | TypeScript | |
MIT License | MIT License |
Stars - the number of stars that a project has on GitHub. Growth - month over month growth in stars.
Activity is a relative number indicating how actively a project is being developed. Recent commits have higher weight than older ones.
For example, an activity of 9.0 indicates that a project is amongst the top 10% of the most actively developed projects that we are tracking.
svgr
-
One way of building an SVG icon library for your project
Really interesting framework agnostic approach, but I think SVGR is a better option for my React homies. It imports an SVG file as a React component. Shouts also to react-icons if Font Awesome, Material Icons and friends are more your bag.
-
Alternative libs to migrate from React to Vue (or Vue to React)
SVGR
-
Power up SVGs with React and CSS
There is another way to import an SVG in Create React App, though. We can import the SVG as a ReactComponent. This is because CRA leverages SVGR to process SVGs.
-
Создаем React-компоненты иконок с помощью Figma API и SVGR. Часть 2.
const { types } = require('@babel/core'); module.exports = { ... template: function svgrCustomTemplate( { imports, interfaces, componentName, props, jsx, exports }, { tpl } ) { // меняем корневой элемент на SvgIcon jsx.openingElement.name.name = 'SvgIcon'; jsx.closingElement.name.name = 'SvgIcon'; // https://github.com/gregberge/svgr/issues/530 // при изменении корневого элемента пропадает спред пропсов // поэтому необходимо добавить спред пропсов самостоятельно jsx.openingElement.attributes.push( types.jSXSpreadAttribute(types.identifier('props')) ); return tpl` ${imports}; import { SvgIcon } from '../SvgIcon'; ${interfaces}; const ${componentName} = (${props}) => ( ${jsx} ); ${exports}; ` } }
-
Using SVGs in Common Lisp web apps with Djula
To solve these problems and have a better development workflow, I have created a package called cl-djula-svg which automates all the above steps for you. The inspiration for this package came from svgr which exactly does the same thing in React applications. It takes a SVG file, process some override logic, optimize it and create React wrapper components based on the SVG content.
-
Some svg icons wont show with react native svg
I normally use SVGR but every time a designer sends me an svg i’ll pass it in svgOmg that deletes all the unnecessary attributes and propietary code from figma, illustrator &co.
- External SVGs that you can style
-
How to debug from this error statement
https://github.com/gregberge/svgr/issues/362 this may help as well.
-
Repeating variable names for imports, types and switch. Got to be a better way!
If you're using Webpack, CRA, or Next.js, you should be using SVGR.
-
How to use SVGs in React
SVGR is the library that powers this ability. Setting it up could be a little hairy, thankfully many popular frameworks (Create React App, Gatsby) support this feature out of the box.
rollup-plugin-visualizer
-
PageSpeed / Lighthouse - Reduce unused JavaScript
I think https://github.com/btd/rollup-plugin-visualizer can help with checking which packages are the largest.
-
Using Vite with React
In our "old" build system - I configured webpack-bundle-analyze to inspect bundle chunks and understand what it made of. I added rollup-bundle-visualyzer instead (although there is an issue that the reported size is not correct).
What are some alternatives?
svg-sprite-loader - Webpack loader for creating SVG sprites.
vite-plugin-svgr - Vite plugin to transform SVGs into React components
vite - Next generation frontend tooling. It's fast!
svgo - ⚙️ Node.js tool for optimizing SVG files
esbuild - An extremely fast bundler for the web
awesome-vite - ⚡️ A curated list of awesome things related to Vite.js
webpack-bundle-analyzer - Webpack plugin and CLI utility that represents bundle content as convenient interactive zoomable treemap
raw-loader - A loader for webpack that allows importing files as a String
vite-tsconfig-paths - Support for TypeScript's path mapping in Vite
nivo - nivo provides a rich set of dataviz components, built on top of the awesome d3 and React libraries
blog-series-nextjs-nx - Source code for the Next.js + Nx blog series