fix: lightningcss fails with html-proxy#13776
fix: lightningcss fails with html-proxy#13776patak-cat merged 6 commits intovitejs:mainfrom Marabyte:fix/lightning-css-proxy
Conversation
|
|
| // This happens with html-proxy (#13776) | ||
| if (!filePath.endsWith('.css')) { | ||
| return src | ||
| } |
There was a problem hiding this comment.
When running the playground, I got "" (empty string) as a value of filePath. I think this doesn't make sense and it's a bug in Lightning CSS. But I think it's fine to merge this as a workaround for now.
|
We can merge this PR as a temporal patch as suggested, but I think more tests are needed and the way |
Description
Fixes a bug when using Lightning CSS with Vite Server and html-proxy
Additional context
The issue was originally found when attempting to use Storybook with + Vitejs 4.4 with the
lightningcssoptioins enabled.The shell app builds but when build the preview iframe it breaks with the error:
node:internal/process/promises:288 triggerUncaughtException(err, true /* fromPromise */); ^ [Error: GenericFailure] { code: 'GenericFailure', plugin: 'vite:css', id: '\x00/iframe.html?html-proxy&direct&index=0.css', pluginCode:[css code] }I would guess the problem is here: https://github.com/vitejs/vite/blob/main/packages/vite/src/node/plugins/css.ts#L2176:L2181
When processing CSS from proxy the
filePathis an empty string or a relative path without a filename so we fail the first condition and try to read the file from the file system.What is the purpose of this pull request?
Before submitting the PR, please make sure you do the following
fixes #123).