Skip to content

fix(webpack-plugin): fix webpack plugin loader dirname path construction#836

Open
yang991178 wants to merge 2 commits intomicrosoft:mainfrom
yang991178:fix/griffel-webpack-plugin-fix-windows-path
Open

fix(webpack-plugin): fix webpack plugin loader dirname path construction#836
yang991178 wants to merge 2 commits intomicrosoft:mainfrom
yang991178:fix/griffel-webpack-plugin-fix-windows-path

Conversation

@yang991178
Copy link
Copy Markdown

The loader in the webpack plugin seems to have an issue on Windows when the path contains spaces. Specifically, new URL(import.meta.url).pathname returns URL-encoded strings (e.g., %20 for spaces), causing webpack to fail when the project path contains spaces. This PR updates the line to use fileURLToPath, which should correctly handle path decoding on all platforms.

In packages/webpack-plugin/src/webpackLoader.mts:

  • Added import for fileURLToPath from 'node:url'
  • Changed const __dirname = path.dirname(new URL(import.meta.url).pathname);const __dirname = path.dirname(fileURLToPath(import.meta.url));

Copilot AI and others added 2 commits April 13, 2026 21:56
On Windows, `new URL(import.meta.url).pathname` returns a URL-encoded
string (e.g., %20 for spaces), causing webpack to fail to resolve the
virtual loader when the project path contains spaces. Using
`fileURLToPath` from `node:url` correctly decodes the path.

Agent-Logs-Url: https://github.com/yang991178/griffel/sessions/ecf6c457-0cf7-4168-b422-06646a01c1d8

Co-authored-by: yang991178 <16064741+yang991178@users.noreply.github.com>
@yang991178 yang991178 requested a review from a team as a code owner April 13, 2026 22:13
@yang991178
Copy link
Copy Markdown
Author

@microsoft-github-policy-service agree

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