forked from gatsbyjs/gatsby
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
docs(www): 25 Workflows - Adding CSS and/or Sass (gatsbyjs#14779)
* chore: cleanup readme for sass plugin * fix: missing guidelist components * fix: consistency between similar docs, headings, and adding beginnings of sass guide * docs: adding to sass guide * Update docs/docs/sass.md Co-Authored-By: Marcy Sutton <marcy@gatsbyjs.com> * Update packages/gatsby-plugin-sass/README.md Co-Authored-By: Marcy Sutton <marcy@gatsbyjs.com> * Apply suggestions from code review Co-Authored-By: Marcy Sutton <marcy@gatsbyjs.com>
- Loading branch information
Showing
7 changed files
with
126 additions
and
48 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
--- | ||
title: Using Sass in Gatsby | ||
--- | ||
|
||
[Sass](https://sass-lang.com) is an extension of CSS, adding nested rules, variables, mixins, selector inheritance, and more. In Gatsby, Sass code can be translated to well-formatted, standard CSS using a plugin. | ||
|
||
Sass will compile `.sass` and `.scss` files to `.css` files for you, so you can write your stylesheets with more advanced features. | ||
|
||
> **Note**: the difference between using a `.sass` or `.scss` file is the syntax that you write your styles in. All valid CSS is valid SCSS as well so it is the easiest to use and most popular. You can read more about the differences in the [Sass documentation](https://sass-lang.com/documentation/syntax). | ||
## Installing and Configuring Sass | ||
|
||
This guide assumes that you have a Gatsby project set up. If you need to set up a project, head to the [**Quick Start guide**](/docs), then come back. | ||
|
||
1. Install the Gatsby plugin [**gatsby-plugin-sass**](/packages/gatsby-plugin-sass/). | ||
|
||
`npm install --save gatsby-plugin-sass` | ||
|
||
2. Include the plugin in your `gatsby-config.js` file. | ||
|
||
```javascript:title=gatsby-config.js | ||
plugins: [`gatsby-plugin-sass`], | ||
``` | ||
|
||
> **Note**: You can configure [additional plugin options](/packages/gatsby-plugin-sass/#other-options) like paths to include and options for `css-loader`. | ||
3. Write your stylesheets as `.sass` or `.scss` files and require or import them as normal. | ||
|
||
```css:styles.scss | ||
$font-stack: Helvetica, sans-serif; | ||
$primary-color: #333; | ||
|
||
body { | ||
font: 100% $font-stack; | ||
color: $primary-color; | ||
} | ||
``` | ||
|
||
```css:styles.sass | ||
$font-stack: Helvetica, sans-serif | ||
$primary-color: #333 | ||
body | ||
font: 100% $font-stack | ||
color: $primary-color | ||
``` | ||
|
||
```javascript | ||
import "./styles.scss" | ||
import "./styles.sass" | ||
``` | ||
|
||
## Other resources | ||
|
||
- [Introduction to Sass](https://designmodo.com/introduction-sass/) | ||
- [Sass Documentation](https://sass-lang.com/documentation) | ||
- [Gatsby starters that use Sass](/starters/?c=Styling%3ASCSS) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters