0

I created a fresh project using create-react-app and typescript and added a sass file in my project (in create-react-app docs it says that it supports sass file out of the box) but I'm getting this error for my sass file:

Failed to compile.

./src/homepage.style.sass (./node_modules/css-loader/dist/cjs.js??ref--6-oneOf-5-1!./node_modules/postcss-loader/src??postcss!./node_modules/resolve-url-loader??ref--6-oneOf-5-3!./node_modules/sass-loader/dist/cjs.js??ref--6-oneOf-5-4!./src/homepage.style.sass)
SassError: Invalid CSS after ".homepage {": expected "}", was "{"
        on line 1 of /home/taghi/wt-projects/react-ecommerce/src/homepage.style.sass
>> .homepage { {

   -----------^

and here is my Sass file content:

.homepage {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 20px 80px;
}

.directory-menu {
  width: 100%;
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
}

.menu-item {
  min-width: 30%;
  height: 240px;
  flex: 1 1 auto;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 1px solid black;
  margin: 0 7.5px 15px;

  &:first-child {
    margin-right: 7.5px;
  }

  &:last-child {
    margin-left: 7.5px;
  }

  .content {
    height: 90px;
    padding: 0 25px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    border: 1px solid black;

    .title {
      font-weight: bold;
      margin-bottom: 6px;
      font-size: 22px;
      color: #4a4a4a;
    }

    .subtitle {
      font-weight: lighter;
      font-size: 16px;
    }
  }
}

Any help would be appreciated

2
  • 1
    SASS syntax is indent based, it doesn't use braces.... so just change your file to a .scss file Commented Apr 22, 2020 at 8:08
  • good call, That was the problem and it's working now. Thanks @TomFinney Commented Apr 22, 2020 at 8:13

2 Answers 2

1

Sass does not need curly brackets and semicolons. So it should look like this,

.homepage display: flex flex-direction: column align-items: center padding: 20px 80px

You can just remove the curly brackets and semicolons in the current CSS code or json Formatter to convert CSS to SASS.

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

Comments

0

It doesn't need "{}",only use indentation

.homepage 
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 20px 80px;

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.