You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: source/installing-with-npm/index.html.md.erb
+20-20Lines changed: 20 additions & 20 deletions
Original file line number
Diff line number
Diff line change
@@ -11,19 +11,19 @@ weight: 10
11
11
12
12
GOV.UK Frontend requires Node.js version 12.17.0 or later to support ECMAScript (ES) modules. Where possible, we recommend you install the latest Long Term Support (LTS) version.
13
13
14
-
2. `cd` to the root of your project and check if you have a [`package.json` file](https://docs.npmjs.com/files/package.json). If you do not have the file, create it by running:
14
+
2. `cd` to the root of your project and check if you have a [package.json file](https://docs.npmjs.com/cli/v11/configuring-npm/package-json). If you do not have the file, create it by running:
15
15
16
16
```
17
17
npm init
18
18
```
19
19
20
20
3. Install [Dart Sass](https://www.npmjs.com/package/sass) - version 1.79.0 or higher.
21
21
22
-
You might see deprecation warnings when compiling your Sass. If required, you can [silence deprecation warnings caused by dependencies](../include-css/#silence-deprecation-warnings-from-dependencies-in-dart-sass).
22
+
You might see deprecation warnings when compiling your Sass. If required, you can [silence deprecation warnings caused by dependencies](/include-css/#silence-deprecation-warnings-from-dependencies-in-dart-sass).
23
23
24
-
Do not use either LibSass or Ruby Sass as they are no longer supported by the Sass developers or GOV.UK Frontend. Projects using these compilers should [migrate to Dart Sass](https://sass-lang.com/blog/libsass-is-deprecated#how-do-i-migrate) as soon as possible.
24
+
Do not use either LibSass or Ruby Sass as they are no longer supported by the Sass developers or GOV.UK Frontend. Projects using these compilers should [migrate to Dart Sass](https://sass-lang.com/blog/libsass-is-deprecated/#how-do-i-migrate) before updating to GOV.UK Frontend v6.0.
25
25
26
-
You can also [install Nunjucks v3.0.0 or later](https://www.npmjs.com/package/nunjucks) if you want to [use GOV.UK Frontend's Nunjucks macros](../use-nunjucks/).
26
+
You can also [install Nunjucks v3.0.0 or later](https://www.npmjs.com/package/nunjucks) if you want to [use GOV.UK Frontend’s Nunjucks macros](/use-nunjucks/).
When the installation finishes, the `govuk-frontend` package will be in your `node_modules` folder.
37
37
38
-
## Get the CSS, Assets and JavaScript working
38
+
## Add HTML for a component
39
39
40
-
Add the HTML for a component to your application. We recommend the accordion component as this makes it easier to spot if JavaScript is not working.
40
+
Add the HTML for a component to your application. We recommend the accordion component as this makes it easy to spot if JavaScript is not working.
41
41
42
42
Go to the [example accordion component](https://design-system.service.gov.uk/components/accordion/#accordion-example) on the GOV.UK Design System website, then copy the HTML.
43
43
44
44
Paste the HTML into a page or template in your application.
45
45
46
-
### Get the CSS working
46
+
## Get the CSS working
47
47
48
48
1. Copy the `/node_modules/govuk-frontend/dist/govuk/govuk-frontend.min.css` file into your application.
49
49
50
50
2. Add your CSS file to your page layout if you need to. For example:
@@ -61,33 +61,33 @@ Paste the HTML into a page or template in your application.
61
61
62
62
The accordion will use a generic font until you get the font and images working, and will not be interactive until you get the JavaScript working.
63
63
64
-
There are also different ways you can [import GOV.UK Frontend's CSS](../include-css/), including into your project's main Sass file:
64
+
There are also different ways you can [include GOV.UK Frontend’s CSS](/include-css/), including into your project’s main Sass file:
65
65
66
66
```scss
67
-
@import "node_modules/govuk-frontend/dist/govuk";
67
+
@use "node_modules/govuk-frontend/dist/govuk" as *;
68
68
```
69
69
70
-
### Get the font and images working
70
+
## Get the font and images working
71
71
72
-
Your component will not use the right font or images until you've added GOV.UK Frontend's assets to your application.
72
+
Your component will not use the correct font or images until you’ve added GOV.UK Frontend’s assets to your application.
73
73
74
74
1. Copy the following 3 items:
75
+
75
76
- `/node_modules/govuk-frontend/dist/govuk/assets/images` folder to `<YOUR-APP>/assets/images`
76
77
- `/node_modules/govuk-frontend/dist/govuk/assets/fonts` folder to `<YOUR-APP>/assets/fonts`
77
78
- `/node_modules/govuk-frontend/dist/govuk/assets/manifest.json` file to `<YOUR-APP>/assets`
78
79
79
-
2. Run your application, then use [the Fonts tab in Firefox Page Inspector](https://developer.mozilla.org/en-US/docs/Tools/Page_Inspector/How_to/Edit_fonts#The_Fonts_tab) to check the accordion is using the GDS Transport font.
80
+
2. Run your application, then use [the Fonts tab in Firefox Page Inspector](https://firefox-source-docs.mozilla.org/devtools-user/page_inspector/how_to/edit_fonts/index.html#The_Fonts_tab) to check the accordion is using the GDS Transport font.
80
81
81
-
In your live application, we recommend [using an automated task or your build pipeline](../import-font-and-images-assets/) instead of copying the files manually.
82
+
You can also [configure how GOV.UK Frontend locates its font and image assets](/import-font-and-images-assets/) to suit your application architecture.
82
83
83
-
### Get the JavaScript working
84
+
## Get the JavaScript working
84
85
85
86
1. Add the following to the top of the `<bodyclass="govuk-template__body">` section of your page template:
2. Copy the `/node_modules/govuk-frontend/dist/govuk/govuk-frontend.min.js` file into your application.
92
92
93
93
3. Import the file before the closing `</body>` tag of your page template, then run the `initAll` function to initialise all the components. For example:
@@ -107,9 +107,9 @@ In your live application, we recommend [using an automated task or your build pi
107
107
108
108
In your live application, we recommend:
109
109
110
-
- [using an automated task or your build pipeline](../import-javascript/) instead of copying the files manually
111
-
- importing only the components your application uses and [using `createAll` to initialise](../import-javascript/#import-individual-components) all their instances on the page
110
+
- [using an automated task or your build pipeline](https://frontend.design-system.service.gov.uk/import-javascript/) instead of copying the files manually
111
+
- importing only the components your application uses and [using createAll to initialise](/import-javascript/#import-individual-components) all their instances on the page
112
112
113
113
Make sure you import all the components used throughout your application or some components will not work correctly for disabled users who use assistive technologies.
114
114
115
-
Once your testing is complete you can use the full code for page layouts and other components from the [Design System website](https://design-system.service.gov.uk/).
115
+
Once your testing is complete, you can use the full code for page layouts and other components from the [Design System website](https://design-system.service.gov.uk/).
0 commit comments