Skip to content

Commit 799e57a

Browse files
Merge pull request #314 from jwthomson/recipe-ui-cdn-to-npm
Update "cdn-to-npm" recipe for SAFE v5
2 parents f57bb80 + 4756143 commit 799e57a

File tree

2 files changed

+23
-0
lines changed

2 files changed

+23
-0
lines changed

docs/recipes/ui/cdn-to-npm.md

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
# How do I migrate from a CDN stylesheet to an NPM package?
2+
Often, referencing a stylesheet from a CDN is all that's needed to add new styles but you can use an NPM package instead.
3+
---
4+
5+
#### 1. Remove the CDN Reference
6+
Remove the CDN reference from the index template in `src/Client/index.html`:
7+
```html
8+
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/[email protected]/css/bulma.min.css">
9+
```
10+
11+
#### 2. Add the NPM Package
12+
Add styles from NPM. [How do I add an NPM package to the client?](../../package-management/add-npm-package-to-client)
13+
In this example we will add the [Bulma NPM package](https://www.npmjs.com/package/bulma).
14+
15+
#### 3. Add a reference to your stylesheet
16+
1. Add a stylesheet to your project using [this recipe](../add-style). Add a scss file instead of a css file.
17+
1. Add the following lines to your scss file:
18+
```scss
19+
// Set variables to affect Bulma styles
20+
$body-color: #c6538c;
21+
@import 'bulma/bulma.sass';
22+
```

mkdocs.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,7 @@ nav:
7676
- Add daisyUI support: "recipes/ui/add-daisyui.md"
7777
- Add Feliz support: "recipes/ui/add-feliz.md"
7878
- Add FontAwesome support: "recipes/ui/add-fontawesome.md"
79+
- Migrate from a CDN stylesheet to an NPM package: "recipes/ui/cdn-to-npm.md"
7980
- Storage:
8081
- Quickly add a database: "recipes/storage/use-litedb.md"
8182
- JavaScript:

0 commit comments

Comments
 (0)