Urthen / case-sensitive-paths-webpack-plugin

Enforces case sensitive paths in Webpack requires.
MIT License
428 stars 45 forks source link

Module not found error; 2 files with same name but different extension #32

Closed marclove closed 6 years ago

marclove commented 6 years ago

When I have two files in the same directory: one being a React component named Select.jsx and the other being a corresponding CSS module named select.scss, I get the following error, which I believe is incorrect (or at least misleading in its message):

Module not found: Error: [CaseSensitivePathsPlugin] `/app/assets/components/forms/Select.scss` does not match the corresponding path on disk `select.scss`.

If I change the name of the scss file to literally anything else (including the import statement within the jsx file), everything works fine. I've looked at the plugin's source code and haven't found any indication that it's ignoring file extensions, but it seems like that's what's going on. Am I missing something obvious in the source code or is something else causing this false positive?

I can move the scss file to another directory and that also fixes it, but I would rather not create a separate directory and I like giving the CSS module the same name as the React component it corresponds to.

(I'm using this plugin in the context of a Rails app via webpacker. I doubt that has any relevance, but including it just in case.)

Appreciate any help you can provide.

Urthen commented 6 years ago

Hi Marc,

I'm unable to replicate this on my Windows machine nor from the Bash subsystem. With the appropriate files cased properly, I tried importing ./components/App and ./components/app.css, no problems, change App.js on disk to app.js and got the error as expected.

Have you tried running the webpack build without webpacker? I am not familiar with it so don't know what it might be doing.

billmers commented 6 years ago

FWIW I have the same issue. I'm also running Rails on OSX with the webpacker gem providing the base webpack config. Must be something funky in there; for now I removed the plugin: environment.plugins.delete('CaseSensitivePaths')

Any ideas on how I might go about diagnosing this? Thanks!

Urthen commented 6 years ago

Hey folks,

Have either of you been able to replicate outside of Rails running webpack natively? I don't want to state that I explicitly don't support it, but I don't use it so really have no idea what it might be doing differently. If it works in native webpack but not Rails, someone more familiar with that ecosystem would have to take a look at why things are failing.

Urthen commented 6 years ago

Hi @billmers and @marclove - Without more information I'm unable to help further, please let me know if you're able to get this working without Webpacker. If it's a webpacker-specific issue, I'm not sure if I can help without someone familiar with Ruby investigating the source.

Urthen commented 6 years ago

Closing due to inactivity.