Skip to content

Commit 572e22f

Browse files
authored
Merge pull request #622 from alphagov/css-changes
Update content for sass modules
2 parents 4f9178d + 7dff5b2 commit 572e22f

7 files changed

Lines changed: 260 additions & 188 deletions

File tree

netlify.toml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,11 @@
1919
to = "/configure-components/"
2020
status = 301
2121

22+
[[redirects]]
23+
from = "/import-css/"
24+
to = "/include-css/"
25+
status = 301
26+
2227
# Asset filenames with fingerprint hashes (which at the minute is only the font
2328
# from GOV.UK Frontend) are given an 'infinite' max-age and treated as
2429
# immutable.

source/import-css/index.html.md.erb

Lines changed: 0 additions & 152 deletions
This file was deleted.

source/import-font-and-images-assets/index.html.md.erb

Lines changed: 17 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,14 @@ To use the font and image assets from GOV.UK Frontend, you can either:
1111
- copy the font and image files into your application
1212

1313
## Serve the assets from the GOV.UK Frontend assets folder - recommended
14+
- serve the assets from the GOV.UK Frontend assets folder (recommended)
15+
- copy the font and image files into your application
16+
17+
## Serve the assets from the GOV.UK Frontend assets folder
1418

1519
Set up your routing so requests for files in `<YOUR-SITE-URL>/assets` are served from `/node_modules/govuk-frontend/dist/govuk/assets`.
1620

17-
For example if you're using [express.js](https://expressjs.com/), add the following to your `app.js` file:
21+
For example if you use the web framework [Express.js](https://expressjs.com/), add the following to your `app.js` file:
1822

1923
```javascript
2024
const path = require('path');
@@ -23,7 +27,7 @@ app.use('/assets', express.static(path.join(__dirname, '/node_modules/govuk-fron
2327

2428
## Copy the font and image files into your application
2529

26-
If you decide to copy the assets instead, copy the:
30+
If you decide to copy the assets instead, copy these 3 items:
2731

2832
- `/node_modules/govuk-frontend/dist/govuk/assets/images` folder to `<YOUR-APP>/assets/images`
2933
- `/node_modules/govuk-frontend/dist/govuk/assets/fonts` folder to `<YOUR-APP>/assets/fonts`
@@ -33,24 +37,23 @@ You should use an automated task or your build pipeline to copy the files, so yo
3337

3438
### If you have your own folder structure
3539

36-
If you use a different folder structure than `<YOUR-APP>/assets/images` and `<YOUR-APP>/assets/fonts`, you can set Sass variables so that Sass builds the CSS to point to your folders.
37-
38-
Set one of the following before the `@import` line in your Sass file:
39-
40-
- `$govuk-assets-path`
41-
- `$govuk-images-path` and `$govuk-fonts-path`
40+
If you use a different folder structure than `<YOUR-APP>/assets/images` and `<YOUR-APP>/assets/fonts`, you can [configure GOV.UK Frontend](/include-css/#configure-gov-uk-frontend) so that Sass builds the CSS according to your folder structure.
4241

43-
Set the `$govuk-assets-path` variable if your `font` and `image` folders have the same parent folder. For example:
42+
Configure the [`$govuk-assets-path`](/sass-api-reference/#govuk-assets-path) variable if your `font` and `image` folders have the same parent folder. For example:
4443

4544
```scss
46-
$govuk-assets-path: "/<YOUR-ASSETS-FOLDER>/";
45+
@use "node_modules/govuk-frontend/dist/govuk" as * with (
46+
$govuk-assets-path: "/<YOUR-ASSETS-FOLDER>/"
47+
);
4748
```
4849

49-
Set the `$govuk-images-path` and `$govuk-fonts-path` variables if your `font` and `image` folders have different parent folders. For example:
50+
Configure the [`$govuk-images-path`](/sass-api-reference/#govuk-images-path) and [`$govuk-fonts-path`](/sass-api-reference/#govuk-fonts-path) variables if your `font` and `image` folders have different parent folders. For example:
5051

5152
```scss
52-
$govuk-images-path: "/<YOUR-IMAGES-FOLDER>/";
53-
$govuk-fonts-path: "/<YOUR-FONTS-FOLDER>/";
53+
@use "node_modules/govuk-frontend/dist/govuk" as * with (
54+
$govuk-images-path: "/<YOUR-IMAGES-FOLDER>/",
55+
$govuk-fonts-path: "/<YOUR-FONTS-FOLDER>/"
56+
);
5457
```
5558

56-
You can also use your own function to generate paths, for example if you're using `asset-pipeline` in [sass-rails](https://github.com/rails/sass-rails). Set the `$govuk-image-url-function` and `$govuk-font-url-function` variables to the name of your function.
59+
You can also use your own function to generate paths, for example if youre using `asset-pipeline` in [sass-rails](https://github.com/rails/sass-rails). Configure the [`$govuk-image-url-function`](/sass-api-reference/#govuk-image-url-function) and [$govuk-font-url-function](/sass-api-reference/#govuk-font-url-function) variables with the function you need to use.

source/importing-css-assets-and-javascript/index.html.md.erb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,6 @@ prevent_indexing: true
99

1010
This content has moved. You can now find out how to import CSS, assets and javascript as 3 separate pages in the following locations:
1111

12-
- [Import CSS](../import-css/)
12+
- [Import CSS](../include-css/)
1313
- [Import font and images assets](../import-font-and-images-assets/)
1414
- [Import JavaScript](../import-javascript/)

0 commit comments

Comments
 (0)