Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

CSS Sass Basics (retired) Variables, Mixins, and Extending Selectors Defining Variables

Todd Squitieri
Todd Squitieri
8,001 Points

Do I need to continually load SASS on my terminal before seeing changes?

I've been working through the Sass tutorials, but never see any of the changes that I've made to the scss file after refreshing the browser.

Do I need to type something in the terminal or gitbash to sync the files and see the changes?

Any help would be much appreciated.

Thanks so much,

T

10 Answers

Chris Shaw
Chris Shaw
26,676 Points

Hi Todd,

Are you pointing your HTML file to the compiled source that Sass generates for you? This is typically a .css file that lives in a css or stylesheets folder in the same directory as your scss or sass folder.

If you are do you have the sass --watch command running in terminal which listens for file changes on your source files.

Todd Squitieri
Todd Squitieri
8,001 Points

Hi Chris,

Thanks so much for the reply. Because I'm still just a beginner, I'm not sure what you mean when you say "pointing the HTML file." I can tell you what I am doing, however: Every time, I open and extract the project files in the lesson. Then, I open the index.html file in Sublime, along with the css file and the scss file. I also right click the index.html file and open it up in the browser so that I can observe any changes that take place after I have edited the files. I do NOTHING with the terminal. I don't even open it. Is this wrong?? Should I be doing something with the terminal?

Should I be typing sass --watch in the terminal every time I work with Sass? If so, I'm wondering what the connection is between the terminal and the sass files (the index.html, the .css file, and the .scss file). I'm not sure I get it, but any help would be awesome.

Thanks again, Chris, for replying to me. I appreciate it.

Sincerely,

Todd

Chris Shaw
Chris Shaw
26,676 Points

I would recommend that you go back and watch installing and using Sass as this is a key and core step when working with Sass as any time you change your .sass or .scss files they need to be recompiled into normal CSS.

Todd Squitieri
Todd Squitieri
8,001 Points

Every time I use the sass --watch main.scss:main.css command in the terminal, I get the following error: error: main.scss (Line 29: invalid css after " } ": expected selector or at -rule, was "}").

What is the terminal telling me here?

I watched the video tutorial, but it doesn't seem to have the information I am looking for. There is some decent documentation here, and I've tried using some of the coding, but I'm not getting anywhere. I just keep creating this sass cache folder on my Desktop, but there are no other changes.

Sorry, but am a little confused. = /

-T

Chris Shaw
Chris Shaw
26,676 Points

Hi Todd,

This is telling you that you have an error on line 29 of your main.scss file, double check all your curly braces are closed, all selectors are valid and you have correctly formatted everything up until the point of the error, if you post your code that would help as well as then we can debug the problem together instead of going back and forth.

https://teamtreehouse.com/forum/posting-code-to-the-forum

Todd Squitieri
Todd Squitieri
8,001 Points

I don't want to confuse issues here, but even with those errors I showed above, the scss and css files aren't connected. In my most recent attempt to figure out this problem, I used the command sass watch main.scss:main.css in the terminal to have sass watch the Project Folder files which I extracted and then saved to my Desktop. I followed the tutorial to a tee, but noticed that the code for the scss file was all white in the Sublime text editor which signaled to me that something was wrong.

I'm less concerned with the line 29 error and more concerned with the fact that my files aren't syncing properly. Here's my code for the scss file, just in case the problem is with my coding:

@mixin roundy($radius, $color) {
    border-radius: $radius-one;
    border-top-right-radius: $radius * 2;
    border-bottom-left-radius: radius * 2;
        a {
            color: $color;
        }
}

.box {
  @include roundy (4px);
}

// A whole bunch of other code
.button {
  @include roundy(2px, red);
  background: #345;
}

And my css file is this:

.box {
  border-radius: 4px;
  border-top-right-radius: 8px;
  border-bottom-left-radius: 8px; }

.button {
  border-radius: 4px;
  border-top-right-radius: 8px;
  border-bottom-left-radius: 8px;
  background: #345; }

Notice that the css file isn't recognizing the changes made to the scss file. I think the problem is that I'm not running the server properly. How do I get Sass to register the changes that I'm making to both files? How do I get both files to look at each other?

I'm sure this problem isn't complicated, which is why I'm growing increasingly frustrated by my inability to figure this out on my own.

Any push in the right direction, of course, would be awesome.

Sorry for pressing this issue further, but I am just dying to figure out what's wrong.

T

Chris Shaw
Chris Shaw
26,676 Points

There is a very important part of Sass that is the reason behind the problem you're having, whenever an error is encountered Sass will NOT compile your source file to a .css file, instead it will fail and give you an error like it is.

To fix the error simply change your mixing declaration to the below and you should be good to go.

@mixin roundy($radius, $color: null)

You can learn more about what null means in Sass by reading Guil's article on the Treehouse blog.

Todd Squitieri
Todd Squitieri
8,001 Points

I changed the coding, as you recommended, but I still don't see any of the changes being made in the css file. I may need to make a video of this or something, because the more I harp on this problem, the more confused I get.

Are you sure this doesn't have anything to do with making certain the server works properly? I mean, do I need to keep re-installing the sass gem or something?

-T

Chris Shaw
Chris Shaw
26,676 Points

Hi Todd,

I'm a heavy user of Sass so I'm very sure it's not a server problem =)

One thing you need to keep in mind is the terminal window running sass --watch needs to be open at all times when editing Sass files, if this is not open no changes can be seen therefore the compiled .css file in the css folder won't change.

Todd Squitieri
Todd Squitieri
8,001 Points

Hi Chris,

But the terminal IS always open! I am using Gitbash for my work, and I make sure I'm on the Desktop in the terminal because that's where I save my files. I am using Sass version 3.4.4 on a Windows computer. I am going to try one more time to fix this problem and if it doesn't work, I'm going to make a vimeo video and then post the link here. Shouldn't take more than two minutes, max.

I swear I'm not making this stuff up!

-T

UPDATE: Here's my video: click here.

Tarik Hamilton
Tarik Hamilton
6,799 Points

I'm new to Sass, so I may not be correct--especially since you didn't get any errors, but typically you can't use variables that do not have any values or not have been declared. In your video, you're popping in variables that don't exist yet or have any value.

Like I said, not sure if that is applicable to Sass because up until now, I used a different app with a GUI to process my Sass.

Todd Squitieri
Todd Squitieri
8,001 Points

Hi Tarik,

Thanks so much for assisting. I don't seem to be having too many problems at this point. I make sure that I'm always in the right folder (within the terminal) and then activate the files from within, using the --watch main.scss:main.css command. This seems to do the trick just fine... at this point.

If anything comes up, I'll definitely make sure to bring it up in the forums! :)

Thanks again,

T

Tarik Hamilton
Tarik Hamilton
6,799 Points

I realized you were using mixins, so my comment was incorrect, but glad you got it working.

I am using Scout for the Sass processing features. I point Scout to the correct source and then save the main.scss file and it keeps track of the overwrites. I am very new to css and this course is really pulling my web dev skills in regards to knowing where everything is located. I am so glad I love Command Line Interface (CLI) and understand how directories work, this has saved me from some real discouragement. Right now I am just limping along with the course. I think it will be clearer as I get more css under my belt.

I was having similar issues using Sass from the command prompt; it appeared that the only update to the css file was made when I first ran --watch . but nothing else happened beyond that when updates were made to the scss file. I switched over to Mixture and everything worked normal; css file was updated as the scss file was updated.