svgr icon indicating copy to clipboard operation
svgr copied to clipboard

How I can use svgr with rollup with query parameters for import

Open romanlex opened this issue 3 years ago • 2 comments

Hello! With webpack I can use imports for svg as https://react-svgr.com/docs/webpack/#use-svgr-and-asset-svg-in-the-same-project How I can use query params for import with rollup for svg imports?

romanlex avatar Dec 09 '22 11:12 romanlex

Just got this issue too. I write a plugin to solve my problem rollup-plugin-resource-query.

import url from '@rollup/plugin-url'
import svgr from '@svgr/rollup'
import resourceQuery from 'rollup-plugin-resouce-query'

export default {
  plugins: [resourceQuery({ resourceQuery: 'url' }), url(), svgr()],
  input: 'src/main.js',
  output: {
    file: 'bundle.js',
    format: 'cjs',
  },
}

It solve issue in my project at least. hope someone came across this post can benefit from it. 😄

allen79yu avatar Mar 06 '23 15:03 allen79yu

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

stale[bot] avatar May 21 '23 19:05 stale[bot]