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 trialJames Barnett
39,199 PointsUsing Sass with Workspaces (a step-by-step guide)
This is a simple example of how to use Sass with Workspaces, this tutorial includes 3 parts.
- Setting up our Workspace and using some basic HTML structure taken from the Sass Basics course.
- Testing out Sass with the
watch
feature and some Sass code also taken from the Sass Basics course. - Starting with opening our Workspace, running the Sass'
watch
feature, making a simple change, watching the styling change in our HTML file
Part 1 - Getting Ready
- Go to Installing and Using Sass and download the project files
- Extract the
final
directory from the project files zip you downloaded in the previous step - Go to Workspaces and create a new
sass
workspace - Open the
final
directory you extracted in earlier and drag theindex.html
file into your new Sass Workspace - Preview the
index.html
file you added to your Workspace in the previous step
Part 2 - Sass Magic
- In your Console in your Workspace type
sass --watch .
- Open the
final
directory you extracted and drag themain.scss
file into your workspace - Preview the
index.html
file to see styling changes - Close your Workspace
Part 3 - Making Changes
- Open your Sass Workspace as you would when you are starting a new learning session
- In your Console in your Workspace type
sass --watch .
- Open the
main.scss
file in your Worksapce - Change the color of links
- Save the
main.scss
file - Preview the
index.html
file to see styling changes
9 Answers
Guil Hernandez
Treehouse TeacherThank you for this guide, James Barnett! I just added the link to this post in the course teacher notes.
Richard Nash
24,862 PointsYes, thank you James :-) I will go through everything here and see how it works for me :-)
Also found a great article by Hugo about Sass project architecture that might be of assistance to some newcomers as well :-)
Richard Nash
24,862 PointsThanks for the shout-out Patrick Koch, but it was all Guil Hernandez and James Barnett, i just asked the questions :-)
Cheers,
R
Richard Nash
24,862 Pointsok, so i'm doing this from scratch and not using the "Installing and using Sass" project.
So here is where I am...
- Created a new Sass workspace.
- Set up my project using the SMACSS methodology.
- Created an index.html file with my site on it.
- Took my old CSS and broke it into small partials representing the different elements of my site
- Organized those into folders with manifest files using the @import command to import the partials
- created an app.scss file and @imported all of the manifest partials into the app.scss file...
Now what do I do to get the app.css and app.css.map files that I need?
Do I run the sass --watch command? Anything else? Do I make the app.css file first?
This is where I am stuck James and Guil. Not sure exactly what to do next to actually see my scss be turned into css and be applied to my html.
Thank you for your time and help,
Richard Nash Los Angeles, CA
James Barnett
39,199 PointsDo I run the sass --watch command
If all of you your scss files are in the same directory, run sass --watch .
the .
at the end tells the terminal to look in the current directory, you can also specify any other directory.
Richard Nash
24,862 Pointsok, i put sass --watch in the console and it did this:
treehouse:~/workspace$ sass --watch
What files should I watch? Did you mean something like:
sass --watch input.sass:output.css
sass --watch input-dir:output-dir
Use --trace for backtrace.
So then I put in this:
sass --watch input.app.scss:output.app.css
because I want my app.scss file to make and update my app.css file, and i got this:
treehouse:~/workspace$ sass --watch input.app.scss:output.app.css
Sass is watching for changes. Press Ctrl-C to stop.
error No such file or directory @ rb_sysopen - input.app.scss
so i'm not sure what to do next...
Richard Nash
24,862 Pointsok, i figured it out! XD the specific info i was looking for was in the partials video in the first badge of advanced sass, which was this:
sass --watch scss:css
that is what I was looking for to have all my partials be imported into my app.scss file and then have my app.css file be automatically generated by the console, of whatever magical awesomeness is going on behind the scenes and under the hood :-)
Thank you for your help James Barnett :-)
R
Guil Hernandez
Treehouse TeacherHey Richard Nash,
Yep, that's the --watch
command I usually use. In the Modular CSS with Sass course, I make sure to remind you to use and type the --watch
command in the console (almost) every other video. See 1:19 in this video, for example. :)
Richard Nash
24,862 PointsHi Guil Hernandez,
Thank you for your reply. I think the part that I was not understanding is that the command:
sass --watch scss:css
creates the initial css file as well. I think I made the assumption that this command only added info to the already created app.css file and I assumed there was a separate, longer command that would be needed to create the initial app.css file.
I'm always happy when the way to do something is actually easier than I expected :-)
Thanks for all your hard work :-)
Richard
ztwbzekpvk
12,893 Pointsztwbzekpvk
12,893 PointsI cannot find the files referred to in step 4.