Skip to content

Commit 0d2e712

Browse files
authored
Merge pull request #2123 from uswds/al-update-compile-instructions
USWDS-Site: Add clarity to Phase 2: compile instructions
2 parents 1977efa + 5a7cc3f commit 0d2e712

File tree

2 files changed

+34
-19
lines changed

2 files changed

+34
-19
lines changed

_data/changelogs/docs-getting-started-devs-phase-2.yml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,11 @@ title: "Phase 2: Compile"
22
type: documentation
33
changelogURL:
44
items:
5+
- date: 2023-07-28
6+
summary: Added clarity to the instructions for custom compilers.
7+
affectsGuidance: true
8+
githubPr: 2123
9+
githubRepo: uswds-site
510
- date: 2023-05-11
611
summary: Replaced references to `copySetup` with `copyTheme`.
712
summaryAdditional:

pages/documentation/getting-started-developers/phase-two.md

Lines changed: 29 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -34,25 +34,26 @@ U.S. Web Design System source code is written in Sass, a powerful stylesheet lan
3434

3535
## Introducing uswds-compile
3636

37-
We’ve developed `uswds-compile`, a tool [hosted on GitHub](https://github.com/uswds/uswds-compile), to help teams compile USWDS Sass files. This tool provides simple Gulp 4 functions that copy USWDS static assets into your project and transform USWDS Sass into browser-readable CSS. Additionally, `uswds-compile` applies Autoprefixer to all compiled code to make sure your CSS is browser-compatible.
37+
We recommend using `uswds-compile`, a USWDS tool [hosted on GitHub](https://github.com/uswds/uswds-compile), as a quick way to get up and running with Sass compilation for USWDS.
3838

39-
We recommend using `uswds-compile` as a quick way to get up and running with Sass compilation for USWDS .
39+
This tool provides simple Gulp 4 functions that copy USWDS static assets into your project and transform USWDS Sass into browser-readable CSS. Additionally, `uswds-compile` applies Autoprefixer to all compiled code to make sure your CSS is browser-compatible.
4040

41-
{: .site-note }
42-
Note: One of the benefits of using `uswds-compile` is that it will set up a Sass entry point for you. If you plan on using `uswds-compile`, you can safely skip [About Sass entry points](#about-sass-entry-points) and jump straight to the [step-by-step instructions](#step-1-install-uswds-compile) that explain how to install and use `uswds-compile`.
41+
Later in this guide we will walk you through setting up Sass compilation for your project with `uswds-compile`. To get started, jump ahead to the [Using uswds-compile](#using-uswds-compile) section below.
4342

44-
If you prefer to set up Sass compilation yourself, the next thing you'll need to do is set up (or edit) your Sass entry point.
43+
## Loading USWDS Sass with a custom compiler
44+
If you already have Sass compilation set up on your project, you'll need to load USWDS Sass and your USWDS settings configuration into your Sass entry point.
4545

46-
## About Sass entry points
46+
### About Sass entry points
4747

4848
A project often has many Sass files, but typically, there’s a single file that serves as the root — the “homepage” of the Sass — that links out to the others. This root file is also known as the “Sass entry point.” The Sass entry point is the most important stylesheet file in your project because it tells the compiler what source files make up your Sass codebase. Often, a project's Sass entry point is named something like `index.scss` or `styles.scss`.
4949

50-
### Setting up USWDS in your Sass entry point
51-
If your project does not yet have a Sass entry point, create a file called `index.scss` or `styles.scss`.
50+
### Creating a Sass entry point
51+
If your project does not yet have a Sass entry point, create a file called `index.scss` or `styles.scss`. This file will typically live at the root of your project's Sass directory.
5252

53-
Your project’s Sass entry point is a simple file that will only need to do the following three tasks:
53+
### Loading USWDS in your Sass entry point
54+
Your project’s Sass entry point is a simple file that will need to:
5455

55-
1. Load or define [USWDS settings]({{ site.baseurl }}/documentation/settings/) (required)
56+
1. Load your project's [USWDS settings configuration]({{ site.baseurl }}/documentation/settings/) (required)
5657
2. Load USWDS source code (required)
5758
3. Load your project’s custom Sass (optional)
5859

@@ -61,23 +62,23 @@ For your entry point to complete these tasks, you will need to add the following
6162
```scss
6263
/* styles.scss */
6364

64-
// 1. Load USWDS settings
65-
@forward "uswds-settings.scss";
65+
// 1. Load your project's USWDS settings configuration
66+
@forward "uswds-theme.scss";
6667

6768
// 2. Load USWDS source code
6869
@forward "./path/to/source/uswds";
6970

7071
// 3. Load your project's custom Sass
71-
@forward "project-custom.scss";
72+
@forward "project-styles.scss";
7273
```
7374

7475
Note that each `@forward` reference in this example is tied to one of the tasks listed above.
7576

7677
In plain language, this code says:
7778

78-
1. **Get the instructions**: Get the USWDS settings that tell the Design System how to build the styles. Settings are the first thing you'll need to include in your entry point.
79+
1. **Get the instructions**: Add the USWDS settings configuration that tells the Design System how to build the styles.
7980

80-
In USWDS, settings are Sass variables that can be configured via Sass' `@use...with()` rule. You can find full instructions for configuring USWDS settings, along with a list of all available settings, on the [Settings page]({{ site.baseurl }}/documentation/settings/).
81+
Your settings configuration is the first thing you'll need to include in your entry point. Often, this configuration will live in its own file, which in this example is called `uswds-theme.scss`. You can find full instructions for configuring USWDS settings, along with a list of all available settings, on the [Settings page]({{ site.baseurl }}/documentation/settings/).
8182

8283
2. **Create the foundation**: Build all USWDS styles from these settings.
8384

@@ -87,9 +88,12 @@ In plain language, this code says:
8788

8889
To load the `uswds` package, you must provide a path to its `index.scss` entry point. If you installed USWDS 3 with npm, the complete path to this file is: `./node_modules/@uswds/uswds/packages/uswds/_index.scss`.
8990

90-
3. **Build new work on top of that foundation**: Finally, add any custom project styles built from design system code.
91+
3. **Build new work on top of that foundation**: Finally, add any custom project styles built from Design System code.
92+
93+
After you've loaded the USWDS source code, you can build new styles with USWDS design tokens, functions, and mixins. For the purposes of this guide, we won’t get into custom code, but the important thing to understand is that any custom code should follow the settings configuration and USWDS source code in your Sass entry point.
9194

92-
After you've loaded the USWDS source code, you can build new styles with USWDS design tokens, functions, and mixins. For the purposes of this guide, we won’t get into custom code, but the important thing to understand is that any custom code should follow the settings and USWDS source code in your Sass entry point.
95+
{:.site-note}
96+
**Note:** USWDS relies on [Autoprefixer](https://github.com/postcss/autoprefixer) to make its compiled CSS browser-compatible. If your compiler does not already use Autoprefixer, we strongly encourage that you add it to your project.
9397

9498
## Using uswds-compile
9599
Complete the following steps to install, configure, and use `uswds-compile`:
@@ -104,7 +108,13 @@ npm install @uswds/compile --save-dev
104108

105109
### Step 2: Create a gulpfile
106110

107-
Once installed, create a file called `gulpfile.js` at the root of your project by running the command `touch gulpfile.js` (alternatively, use an existing gulpfile if one already exists). This file will need to do the following:
111+
If your project does not yet have a `gulpfile.js` file, create one at the root of your project by running this command:
112+
113+
```
114+
touch gulpfile.js
115+
```
116+
117+
This file will need to do the following:
108118

109119
1. [Import the `@uswds/compile` package](#step-3-import-the-uswds-compile-package)
110120
2. [Set the project's USWDS version](#step-4-set-uswds-version)
@@ -241,7 +251,7 @@ npx gulp compile
241251

242252
When your `gulpfile.js` is ready, initialize your project to copy all the necessary Sass, image, font, and Javascript assets from the USWDS source code.
243253

244-
Initialize your project and get started by running the following command:
254+
If you defined the `init` export in [Step 6](#step-6-export-compile-functions), you can initialize your project and get started by running the following command:
245255

246256
```bash
247257
npx gulp init

0 commit comments

Comments
 (0)