Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Leaving the SVG as SVG instead of converting to string #6

Open
privatenumber opened this issue Jan 25, 2021 · 1 comment
Open

Leaving the SVG as SVG instead of converting to string #6

privatenumber opened this issue Jan 25, 2021 · 1 comment

Comments

@privatenumber
Copy link

Seems like this plugin is currently doing two things:

  1. Optimizing the SVG with SVGO
  2. Converting it to a JS module and exporting the SVG as a string

The second step makes the plugin un-interoperable with other Rollup plugins that take SVGs as an input.

For example, rollup-plugin-htmlvue takes in SVGs, converts them into a Vue SFC, and lets the Vue plugin then compile it to a JS.

Wondering if this plugin can become more modular by letting the SVG remain a SVG file, and recommending that users that want to import the SVG as a string chain their plugins with something like rollup-plugin-string:

import { rollup } from 'rollup';
import { string } from 'rollup-plugin-string';
import svgo from 'rollup-plugin-svgo'

rollup({
  entry: 'image.svg',
  plugins: [
	// optimize SVG
    svgo(),

	// transform SVG to JS string
    string({
      include: '**/*.svg',
    }),
  ]
});

Although my use-case is with Vue.js, I can imagine this being useful for optimizing SVGs that compile to React or Svetle components too.

@porsager
Copy link
Owner

That's a good idea. If it's still relevant a PR for doing this through an option would be great.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants