-
-
Notifications
You must be signed in to change notification settings - Fork 608
Is there a proper way to import vendor styles from a CSS module? #253
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
Comments
I think one of your first 2 options is the way to go. Going off less-loader readme adding a then try (maybe)
I think imports remain unchanged, css-modules uses composes for transforming imports. May be way off though |
@dbazile any luck so far? I'm still struggling with this. I don't really want to add less-loader since I'm only dealing with plain css in my project. |
For added context, here's what I did so far: Added to webpack.config.js resolve: {
extensions: ['', '.html', '.js', '.json', '.scss', '.css'],
alias: {
leaflet_css: __dirname + "/node_modules/leaflet/dist/leaflet.css"
}
} I also add images via url-loader
And then imported it together with import 'leaflet'
import 'leaflet_css'
import { Map, TileLayer, LayersControl, ScaleControl, Marker, Popup } from 'react-leaflet' The errors I'm seeing are
|
The './images' directory error is caused by this line: For convenience, this is the commit that added this line: |
Theres an issue open under leaflet about this too: |
@stigi: Haven't tried in a while. My temporary workaround has since evolved into a permanent workaround; I just require the vendor CSS in the .JSX file which sidesteps the module scoping. |
Same, but it would be nice if |
@gnarf: That syntax looks like it might lead down a dark path. :D IMO, it should work such that the idiomatic Webpack way works, i.e., |
Adding Another potential solution is to use css-raw-loader only on |
I have the same problem...
The only way to easily fix it is by disabling Two weeks ago the same problem was reported on official Could someone explain what is the expected behaviour here? It seems a bit strange for me that scss / css files in |
Solved: Had similar problem needed to to import bootstrap template into css from scss see below: |
@Origslammer1 while that solution works, what happens when bootstrap updates? The real solution needs to address installed node modules. |
Sorry for delay! PR welcome! |
Not related to |
Everything is working if we use following Thanks 22samuelk |
Are any of the following intended to work?
Background
I'm trying to load the vendor CSS from Leaflet and running into errors because it does relative imports for image assets. What I'd like to have happen is the CSS is loaded and everything in it treated as a global.
I've been scouring the web for a few hours now and couldn't find an answer to this.
Temporary Workaround
I've disabled modules on plain
.css
files and addedimport 'leaflet/dist/leaflet.css';
to the top of the.jsx
file. Is this the happy path? It's certainly the path of least resistance, but it feels odd to have this thing dangling outside of CSS.My guess as to what's happening
My guess is the CSS loader is preempting the LESS loader and doesn't recognize the
:global {}
nesting.Relevant parts of
webpack.config.js
:The text was updated successfully, but these errors were encountered: