0

I feel a bit silly asking this, but I'm having trouble with resolving a relative path in my React app.

Where I want to import the css:

src/components/pages/mypage.js

Where my css file is located:

src/custom_styles/sidebar.css

How I'm trying to import sidebar.css in mypage.js:

import '.../custom_styles/sidebar.css'

This is resulting in Module not found: Can't resolve '.../custom_styles/sidebar.css' in the console when compiling. What am I doing wrong?

1
  • 2
    Only use two periods.import '../custom_styles/sidebar.css' Commented Feb 26, 2020 at 23:55

2 Answers 2

3

import '../../custom_styles/sidebar.css'; in your mypage.js file.

../ means that you're going one level up from your current file. In your case you have to move two ups.

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

Comments

1
import '../../../custom_styles/sidebar.css'

Each time you want o get to the parent folder add ../ so if you want to get to 3 folders above use ../../../ , not .../

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.