1

i am using https://github.com/0wczar/airframe-react and i want to implement there a map with react-leaflet library. When i am trying to import import "leaflet/dist/leaflet.css"; to style my map i got error like this:

ERROR in ./node_modules/leaflet/dist/leaflet.css 3:0 

Module parse failed: Unexpected token (3:0) You may need an appropriate loader to handle this file type, currently no loaders are configured to process this file. See https://webpack.js.org/concepts#loaders | /* required styles */ |

.leaflet-pane, | .leaflet-tile, | .leaflet-marker-icon,

What should i do to resolve this?

0

2 Answers 2

1

Make sure you have css-loader and style-loader as your dev-dependency, if not install them with npm install --save-dev style-loader and then check your webpack config, adding this to your webpack.config.js will do

module.exports = { module: { rules: [ { test: /\.css$/i, use: ['style-loader', 'css-loader'], }, ], }, };

Sign up to request clarification or add additional context in comments.

2 Comments

I do not have webpack.config.js but i have postcss.config.js and I installed style-loader and added code there like that: module.exports = { plugins: [ require('autoprefixer') ], module:{ rules:[ { test:/\.css$/, use:['style-loader','css-loader'] } ] }, };
You will have to specify your post-css config to webpack for the post-css config to actually make effect as specified here github.com/postcss/postcss-loader#usage , try creating webpack.config.js file on the root folder and follow the docs. Hope that'll help.
0

I'm guessing you are using webpack. If so, you'll need to add a webpack loader to handle importing CSS files.

You should be able to use css-loader for your current problem.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.