diff --git a/.changeset/light-wombats-buy.md b/.changeset/light-wombats-buy.md new file mode 100644 index 0000000000..0d93a2ff2a --- /dev/null +++ b/.changeset/light-wombats-buy.md @@ -0,0 +1,5 @@ +--- +"@lynx-js/react-webpack-plugin": patch +--- + +Keep snapshot id unchanged on Windows. diff --git a/packages/webpack/react-webpack-plugin/src/loaders/options.ts b/packages/webpack/react-webpack-plugin/src/loaders/options.ts index 89bf5b7810..352af105ab 100644 --- a/packages/webpack/react-webpack-plugin/src/loaders/options.ts +++ b/packages/webpack/react-webpack-plugin/src/loaders/options.ts @@ -80,10 +80,16 @@ export interface ReactLoaderOptions { transformPath?: string | undefined; } +function normalizeSlashes(file: string) { + return file.replaceAll(path.win32.sep, '/'); +} + function getCommonOptions( this: LoaderContext, ) { - const filename = path.relative(this.rootContext, this.resourcePath); + const filename = normalizeSlashes( + path.relative(this.rootContext, this.resourcePath), + ); const { compat,