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

Incorrect SVGO prefix with prefixIds #343

Closed
johnkhughes opened this issue Jun 8, 2020 · 1 comment
Closed

Incorrect SVGO prefix with prefixIds #343

johnkhughes opened this issue Jun 8, 2020 · 1 comment

Comments

@johnkhughes
Copy link

SVGO lets you set a prefix for id attributes with the prefixIds option. If this is option is set, the default prefix should be the SVG file name. However, when the option is set here, the prefix output in the SVG files is prefix. Here is the relevant part of the script I am using:

return gulp.src('./src/*.svg')
    .pipe(imagemin([
        imagemin.svgo({
            plugins: [
                {
                    prefixIds: {
                        prefix: true
                    }
                }
            ]
        })
    ]))
    .pipe(gulp.dest('./dist'));

My aim was to have the id attributes in each file have a unique prefix to avoid naming collisions when they are embedded in an HTML file. Is there any way to get the default, documented behaviour of SVGO work with Gulp here?

@sindresorhus
Copy link
Owner

This needs to be opened on https://github.com/imagemin/imagemin-svgo. I think await svgo.optimize(buffer); needs to be changed to await svgo.optimize(buffer, {path: somePath});, but it's not clear where somePath would come from as Imagemin doesn't pass the path to plugins.

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