Skip to content

Commit 387276b

Browse files
mdojulien-deramond
andcommitted
Update Sass docs to mention compiling and including
Co-Authored-By: Julien Déramond <[email protected]>
1 parent 0d9715e commit 387276b

File tree

1 file changed

+47
-6
lines changed
  • site/content/docs/5.3/customize

1 file changed

+47
-6
lines changed

site/content/docs/5.3/customize/sass.md

Lines changed: 47 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,10 @@ your-project/
1717
├── scss
1818
│ └── custom.scss
1919
└── node_modules/
20-
└── bootstrap
21-
├── js
22-
└── scss
20+
│ └── bootstrap
21+
│ ├── js
22+
│ └── scss
23+
└── index.html
2324
```
2425

2526
If you've downloaded our source files and aren't using a package manager, you'll want to manually create something similar to that structure, keeping Bootstrap's source files separate from your own.
@@ -28,9 +29,10 @@ If you've downloaded our source files and aren't using a package manager, you'll
2829
your-project/
2930
├── scss
3031
│ └── custom.scss
31-
└── bootstrap/
32-
├── js
33-
└── scss
32+
├── bootstrap/
33+
│ ├── js
34+
│ └── scss
35+
└── index.html
3436
```
3537

3638
## Importing
@@ -85,6 +87,45 @@ In your `custom.scss`, you'll import Bootstrap's source Sass files. You have two
8587

8688
With that setup in place, you can begin to modify any of the Sass variables and maps in your `custom.scss`. You can also start to add parts of Bootstrap under the `// Optional` section as needed. We suggest using the full import stack from our `bootstrap.scss` file as your starting point.
8789

90+
## Compiling
91+
92+
In order to use your custom Sass code as CSS in the browser, you need a Sass compiler. Sass ships as a CLI package, but you can also compile it with other build tools like [Gulp](https://gulpjs.com/) or [Webpack](https://webpack.js.org/), or with a GUI applications. Some IDEs also have Sass compilers built in or as downloadable extensions.
93+
94+
We like to use the CLI to compile our Sass, but you can use whichever method you prefer. From the command line, run the following:
95+
96+
```shell
97+
# Install Sass globally
98+
npm install -g sass
99+
100+
# Watch your custom Sass for changes and compile it to CSS
101+
sass --watch ./scss/custom.scss ./css/custom.css
102+
```
103+
104+
Learn more about your options at [sass-lang.com/install](https://sass-lang.com/install) and [compiling with VS Code](https://code.visualstudio.com/docs/languages/css#_transpiling-sass-and-less-into-css).
105+
106+
{{< callout info >}}
107+
**Using Bootstrap with another build tool?** Consider reading our guides for compiling with [WebPack]({{< docsref "/getting-started/webpack" >}}), [Parcel]({{< docsref "/getting-started/parcel" >}}), or [Vite]({{< docsref "/getting-started/vite" >}}). We also have production-ready demos in [our examples repository on GitHub](https://github.com/twbs/examples).
108+
{{< /callout >}}
109+
110+
## Including
111+
112+
Once your CSS is compiled, you can include it in your HTML files. Inside your `index.html` you'll want to include your compiled CSS file. Be sure to update the path to your compiled CSS file if you've changed it.
113+
114+
```html
115+
<!doctype html>
116+
<html lang="en">
117+
<head>
118+
<meta charset="utf-8">
119+
<meta name="viewport" content="width=device-width, initial-scale=1">
120+
<title>Custom Bootstrap</title>
121+
<link href="/css/custom.css" rel="stylesheet">
122+
</head>
123+
<body>
124+
<h1>Hello, world!</h1>
125+
</body>
126+
</html>
127+
```
128+
88129
## Variable defaults
89130

90131
Every Sass variable in Bootstrap includes the `!default` flag allowing you to override the variable's default value in your own Sass without modifying Bootstrap's source code. Copy and paste variables as needed, modify their values, and remove the `!default` flag. If a variable has already been assigned, then it won't be re-assigned by the default values in Bootstrap.

0 commit comments

Comments
 (0)