cascornelissen / svg-spritemap-webpack-plugin

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

Problem with path.join on windows #199

Closed rnkpplr closed 1 year ago

rnkpplr commented 1 year ago

Hi,

I have upgraded the version from v4.3.3 to v4.5.0. Since then, there are problems when creating the SVG Spritemap locally on Windows computers. It seems, that the input pattern is not being recognised.

I set the path in webpack.config.js with path.join(__dirname, 'projects/default/'). When I run build:prod or watch I get earn the following WARNING:

in svg-spritemap-webpack-plugin No source files match the patterns: 'C:\svg-spritemap-webpack-plugin-test\projects\default\src/assets/icons/*/.svg'.

->and the sprite will not be created. I have temporarily fixed the problem by checking the platform new SVGSpritemapPlugin((process.platform === "win32" ? "projects/default/src/assets/icons/**/*.svg": platform_paths.assets + 'icons/**/*.svg'), {

On Linux systems it runs

Setting: Node v16.17.0, npm 8.15.0, OS Windows 11 Minimal Testcase: https://github.com/rnkpplr/svg-spritemap-webpack-plugin-test

Thanks for watching

cascornelissen commented 1 year ago

This is due to a change that's part of v4.4.2 in the glob dependency that's used for this. There's more information available in https://github.com/cascornelissen/svg-spritemap-webpack-plugin/issues/195 as well as in the release notes for glob@8 but the gist of it is that you need to use forward slashes for the glob pattern and my assumption is that platform_paths.assets uses backslashes?

rnkpplr commented 1 year ago

Yes, there are backslashes in platform_paths.assets. Thanks for the quick answer and thanks for the plugin ;)