Skip to content
This repository has been archived by the owner on Apr 6, 2021. It is now read-only.

css-loader can't handle paths with spaces #22

Closed
rolandleth opened this issue Mar 15, 2021 · 8 comments · Fixed by #106
Closed

css-loader can't handle paths with spaces #22

rolandleth opened this issue Mar 15, 2021 · 8 comments · Fixed by #106

Comments

@rolandleth
Copy link

rolandleth commented Mar 15, 2021

Hey!

If the project is in a folder that has a space in its name anywhere along the path, css-loader breaks, but without spaces it works (that should teach me for using spaces, I know 😅):

Error: ENOENT: no such file or directory, stat '/Users/home/Some%20Projects/a-project/src/styles/index.css'
# or
Error: ENOENT: no such file or directory, stat '/Users/home/Some%20Projects/a-project/tailwind.config.js'

Using tailwindcss in postcss.config.js also works properly, with and without spaces.

The same thing happens in any kind of project (reproduced it in Next.js, and in razzle.js).

@tauzN
Copy link

tauzN commented Mar 15, 2021

This might be related: #18

@rolandleth
Copy link
Author

It looks like it is, so it might not be Vite-related, after all. In which case, we have another type of project that confirms the bug.

@bymayo
Copy link

bymayo commented Mar 15, 2021

I also get the ENOENT: no such file or directory, stat issue, running it through Gulp / PostCSS

@johneatmon
Copy link

Yep, had this same issue using Laravel Mix:

https://gist.github.com/johnnytest4real/6036e55bee447c2cc9b774a67b1345e0

@z-x
Copy link

z-x commented Mar 16, 2021

Confirmed on Windows and a very basic config. Directories with spaces doesn't work.

@surjithctly
Copy link

Yes, I confirm this issue.

Windows, Node 14.16.0.

Although, it doesn't work for me even after that because of the Infinite loop error in next.js

@anuraghazra
Copy link
Contributor

anuraghazra commented Mar 17, 2021

So the issue is with these two lines

let pathname = url.parse(file).pathname
let newModified = fs.statSync(pathname).mtimeMs

Can be fixed by decoding the URI (I'm not really sure why in here url.parse is used to get the pathname of a directory tho 🤔 )

    let pathname = url.parse(file).pathname
    let newModified = fs.statSync(decodeURIComponent(pathname)).mtimeMs

Or by just by passing the file in fs.statSync

    let newModified = fs.statSync(file).mtimeMs

@surjithctly
Copy link

@anuraghazra Great. I think you can create a pull-request with your proposal maybe?

So, you can discuss this with the official team.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

7 participants