How to include “leaflet.css” in a React app with webpack?

前端 未结 6 1668
忘掉有多难
忘掉有多难 2021-01-19 02:09

I using the survivejs.com site as a template to build a map based React app with webpack. For the map i am using leaflet but i can\'t find a way to add the leaflet.css. With

6条回答
  •  天涯浪人
    2021-01-19 02:37

    Webpack can't parse CSS without some help from a loader. The most commonly used CSS loader is webpack/css-loader.

    I disagree with the answer from Lakshman Diwaakar in that I think it is extremely beneficial to import component specific CSS files within the JSX of that component, as it allows all the relevant code for that component to live in one place. If I remove the component, then that CSS is no longer part of any build. If I want to re-use a component then the CSS is right there to go with it.

提交回复
热议问题