-
Notifications
You must be signed in to change notification settings - Fork 18
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Autosuggest.scss could not be resolved. #1
Comments
I was able to get your first problem working by using a custom webpack resolver:
For the second part, I suspect he's using the sass versions of the bootstrap styles - you'll need to add a dependency to bootstrap-sass instead of the normal boostrap css which uses less. |
Hi Viridia, Your fix solved the first issue for me, indeed. I figured out the second issue: the package Thank you for pointing me in the right direction! EDIT: I still had issues with react-bootstrap-autocomplete styles not being merge with react-bootstrap style. I fixed the issued by adding |
As you've discovered, the style import is intended to require some external configuration in your module loader (such as Webpack). I could refrain from importing it at all, and leave that to the applications to do, but that seemed likely to confuse people even more, since it would build but then be unstyled. I'm certainly open to other ways of handling this. And yes, I use Anyway, there are various ways to get Webpack to find all the necessary files. Here's an excerpt of the relevant parts from one of my
Also, here are the relevant node dependencies for that project:
|
I realize this is closed, but wouldn't it make more sense to update the
Otherwise, why even bother building a |
@joekrill: The
If you're using your own bundling tool, such as Webpack, you usually don't want to include already bundled dependencies, as their transitive dependencies will be duplicated (except the ones marked as external, like React). The |
@trevorr That makes sense. It's just unusual to see a module packaged in a way that requires your loader handle being able to require One of those factors I think is actually a bug/problem with the
Which comes from this line in
I can't quite figure out if this is intentional. Surely that import should actually be:
No? |
@joekrill I believe it was intentional, so that it would be easier to customize its handling by the loader. For instance, a customized version in an application could be selected just by having it in the application's source path(s). The Basically, I think it comes down to how likely applications are to override it. My assumption (based on my own applications) was that it would be common. By requiring it in the source, I make sure the styles are loaded. (Otherwise, I'm sure there would be lots of questions about why it looks completely broken because there are no styles.) It would be nice if it would "just work out of the box" without loader configuration, but I'd want to find a way that doesn't make it more difficult to make the customizations that most people are likely going to need eventually. (To be honest, since this was my first big React component, I probably also found other components that worked this way, and followed their lead. Unfortunately, that was long enough ago that I can't remember which ones.) |
@trevorr If an alternative component were to come to the same conclusion, though, then there's a huge problem, because both would be requiring the same "global" module ('Autosuggest.scss', in this case), and there would be no way to distinguish between the two. Is that highly unlikely? Probably. But "Autosuggest" isn't exactly highly unique, either. But ignoring that problem, I'm running into an issue where I'm testing components with node and mocha. No webpack or anything here -- just using |
The consensus seemed to be that |
Hi there,
First of all, great component, it looks absolutely amazing, but I cannot get it to work. I have sass-loader installed, as well as all the dependencies, import the library using RequireJS (
import Autosuggest from 'react-bootstrap-autosuggest'
) but still get the following error when compiling with webpack:Module not found: Error: Cannot resolve module 'Autosuggest.scss'
After editing the
require('Autosuggest.scss');
line in the lib/Autosuggest.js and replacing it by a relative referencerequire('../src/Autosuggest.scss')
, the module can now be found, but compilation still fails when trying to import the styles from Bootstrap:ERROR in ./~/css-loader!./~/sass-loader!./~/react-bootstrap-autosuggest/src/Autosuggest.scss Module build failed: @import "bootstrap/variables"; @import "bootstrap/mixins";
Any clue how to solve the issue? I'd really love to use your component....
The text was updated successfully, but these errors were encountered: