diff --git a/change/@griffel-webpack-plugin-fix-windows-path.json b/change/@griffel-webpack-plugin-fix-windows-path.json new file mode 100644 index 000000000..625e6a325 --- /dev/null +++ b/change/@griffel-webpack-plugin-fix-windows-path.json @@ -0,0 +1,7 @@ +{ + "type": "patch", + "comment": "fix: use fileURLToPath for Windows path compatibility", + "packageName": "@griffel/webpack-plugin", + "email": "hy.liu@berkeley.edu", + "dependentChangeType": "patch" +} diff --git a/packages/webpack-plugin/src/webpackLoader.mts b/packages/webpack-plugin/src/webpackLoader.mts index bfcd86b6c..7707a920a 100644 --- a/packages/webpack-plugin/src/webpackLoader.mts +++ b/packages/webpack-plugin/src/webpackLoader.mts @@ -1,6 +1,7 @@ import { EvalCache, transformSync, type TransformOptions, type TransformResult } from '@griffel/transform'; import type * as webpack from 'webpack'; import * as path from 'node:path'; +import { fileURLToPath } from 'node:url'; import { GriffelCssLoaderContextKey, type SupplementedLoaderContext } from './constants.mjs'; import { generateCSSRules } from './utils/generateCSSRules.mjs'; @@ -10,7 +11,7 @@ export type WebpackLoaderOptions = Omit>; -const __dirname = path.dirname(new URL(import.meta.url).pathname); +const __dirname = path.dirname(fileURLToPath(import.meta.url)); // TODO: do something better, define via exports? const virtualLoaderPath = path.resolve(__dirname, 'virtual-loader', 'index.cjs'); const virtualCSSFilePath = path.resolve(__dirname, 'virtual-loader', 'griffel.css');