cascornelissen / svg-spritemap-webpack-plugin

SVG spritemap plugin for webpack
MIT License
207 stars 49 forks source link

Glob doesn't find anything on windows #191

Closed eyaldar closed 2 years ago

eyaldar commented 2 years ago

Description I have a folder with a bunch of SVG files on windows, I set SVGSpriteMapPlugin like this:

new SVGSpriteMapPlugin(path.join(__dirname,"src","assets","images","vector","workspaceGallery","*.svg").replace(/\\/g,'/'), {
    output: {
        filename: `sprites/workspaceSprites.svg`,
        svgo: true
    },
    sprite: {
        prefix: false,
        generate: {
            title: false
        }
    }
})

But once I run it it seems that path gets normalized here in line 63 back to backslash based lines which doesnt seem to work with glob.sync anymore (updateDependencies function)

I'm pretty sure i'm missing something here because this used to work for me up until I reinstalled the entire node_modules, that being said, I did find this node-glob issue which seems to say the same thing. see also this one

my hacky solution in the meantime is to override use to glob 7.2.0

Expected behavior The svg files are found no matter what system you use

Actual behavior glob doesn't find any svg files if the paths are normalized to windows (using backlashes)

System information Windows 10

Minimal reproduction Minimal Example

cascornelissen commented 2 years ago

Looks like others are also running into this issue:

I can't really test on a Windows setup unfortunately so I'm thinking out loud here... It looks like the allowWindowsEscape option that will be introduced by https://github.com/isaacs/node-glob/issues/468 would solve this? Once that lands you should be able to set it using the input.options option of this plugin.

I can't really make it a default because that could cause breaking changes for users on Windows that actually want to escape characters, which is why the was made in node-glob.

eyaldar commented 2 years ago

Yeah, should be good enough, in the mean time I forced version 7.2.0 and everything works as it used to be.

PurTahan commented 2 years ago

in react native throws same error

nicolas377 commented 2 years ago

Glob 7.2.3 was released a few hours ago, which should contain the fix to this issue.

cascornelissen commented 2 years ago

I'm closing this as this seems to be resolved, feel free to comment if I misinterpreted 😘