cascornelissen / svg-spritemap-webpack-plugin

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

[v3.6.0] Watchpack Error (initial scan): Error: ENOTDIR: not a directory, scandir '/../..' #128

Closed sectsect closed 3 years ago

sectsect commented 3 years ago

I get console errors on watch mode. ☝️ FYI: However, the svg file is generated well.

$ npm run dev
...
[webpack-cli] watching files for updates...
Watchpack Error (initial scan): Error: ENOTDIR: not a directory, scandir '/xxx/xxx/svg-spritemap-webpack-plugin-test/src/assets/svg/facebook.svg'
Watchpack Error (initial scan): Error: ENOTDIR: not a directory, scandir '/xxx/xxx/svg-spritemap-webpack-plugin-test/src/assets/svg/instagram.svg'
Watchpack Error (initial scan): Error: ENOTDIR: not a directory, scandir '/xxx/xxx/svg-spritemap-webpack-plugin-test/src/assets/svg/twitter.svg'
Watchpack Error (initial scan): Error: ENOTDIR: not a directory, scandir '/xxx/xxx/svg-spritemap-webpack-plugin-test/src/assets/svg/youtube.svg'

The error can be resolved by changing the glob pattern as shown below.
Is this the expected behavior?

- new SVGSpritemapPlugin(path.resolve(sourcePath, 'assets/svg/**/*.svg'), {...}),
+ new SVGSpritemapPlugin(path.resolve(sourcePath, 'assets/svg/*'), {...}),

My Test Project

I created a minimal project. (webpack: 5.3.2 / svg-spritemap-webpack-plugin: 3.6.0) https://github.com/sectsect/svg-spritemap-webpack-plugin-test

  1. npm run dev
  2. Check your console.
cascornelissen commented 3 years ago

Interesting, looks like some file dependencies are getting marked as directory dependencies 🤔 Are you sure this does not happen with Webpack 4?

Thanks for the minimal project, I'll look into it later today.

cascornelissen commented 3 years ago

Found the issue and a fix is on the way ✌🏼

cascornelissen commented 3 years ago

This should be fixed in 3.6.1 which is now available under the next dist-tag on NPM.

$ npm install svg-spritemap-webpack-plugin@next

Please test this release out using both Webpack 4 and 5 if possible and report any problems.