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

feat: raw svg support in image plugin #1512

Closed
wants to merge 1 commit into from

Conversation

fooku18
Copy link

@fooku18 fooku18 commented Jun 5, 2023

Rollup Plugin Name: image

This PR contains:

  • bugfix
  • feature
  • refactor
  • documentation
  • other

Are tests included?

  • yes (bugfixes and features will not be merged without tests)
  • no

Breaking Changes?

  • yes (breaking changes will not be merged unless absolutely necessary)
  • no

If yes, then include "BREAKING CHANGES:" in the first commit message body, followed by a description of what is breaking.

List any relevant issue numbers:

Description

These changes are adding a flag for exporting raw content for svg extensions. This tries to replicate Webpacks raw-loader, but only for svg extensions. It comes handy, when a raw include strategy is used within an application.

Usage:

// rollup.config.js
import image from '@rollup/plugin-image';

export default (async () => ({
	input: 'main.js',
	plugins: [
		image({ sourceSvg: true }),
	],
	output: {
		file: 'bundle.js',
		format: 'cjs'
	}
}))();

which will output svg imports as:

var s='<svg role="img" class="svg-icon__icon" focusable="false" viewBox="0 0 22 22" xmlns="http://www.w3.org/2000/svg">    <path d="M12 0h-2v22h2V0Z"/>    <path d="M22 10H0v2h22v-2Z"/></svg>';export{s as default};

These changes are adding a flag for exporting raw content for svg extensions. This tries to replicate Webpacks `raw-loader`, but only for svg extensions. It comes handy, when a raw include strategy is used within an application.
@fooku18 fooku18 requested a review from tjenkinson as a code owner June 5, 2023 07:38
@shellscape
Copy link
Collaborator

Thanks for the PR. typically we like folks to open a modification or feature issue to talk about new features and such. I don't see this being a good addition to the image plugin. That plugin is more generic and has a very narrow function. That's a good thing.

While I think your changes are cool, they're definitely geared specifically to SVG, as that functionality wouldn't be compatible with the other image formats the plugin supports. Because of that I'm not able to give my thumbs up to these changes and I think they'd be better off in a third party plugin.

My response isn't the final answer, as other maintainers here might have a different view.

@shellscape
Copy link
Collaborator

As no one else has responded to the request to review in 60 days, we're going to close this one. Again, we appreciate the PR and your effort. I'm sorry we couldn't accept it at this time.

@shellscape shellscape closed this Aug 11, 2023
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

Successfully merging this pull request may close these issues.

2 participants