Skip to content

Commit 849c56a

Browse files
jonasjabarigitbook-bot
authored andcommitted
GitBook: [#8] Adjusted JS setup docs
1 parent 70e475e commit 849c56a

File tree

4 files changed

+37
-70
lines changed

4 files changed

+37
-70
lines changed

docs/SUMMARY.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@
88

99
* [Installation & Update](getting-started/installation-update/README.md)
1010
* [JS via Webpacker](getting-started/installation-update/js-via-webpacker.md)
11-
* [JS via JSBundling-Rails](getting-started/installation-update/js-via-jsbundling-rails.md)
1211
* [JS via Importmap](getting-started/installation-update/js-via-importmap.md)
12+
* [JS via JSBundling-Rails](getting-started/installation-update/js-via-jsbundling-rails.md)
1313
* [Hello world](getting-started/hello-world.md)
1414

1515
## API

docs/getting-started/installation-update/README.md

Lines changed: 25 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -70,18 +70,18 @@ Don't apply the "matestack-ui" id to the body tag.
7070

7171
### JavaScript installation
7272

73-
#### Rails 7 importmap based installation
74-
75-
{% content-ref url="js-via-importmap.md" %}
76-
[js-via-importmap.md](js-via-importmap.md)
77-
{% endcontent-ref %}
78-
7973
#### Webpacker > 5.x based JavaScript installation
8074

8175
{% content-ref url="js-via-webpacker.md" %}
8276
[js-via-webpacker.md](js-via-webpacker.md)
8377
{% endcontent-ref %}
8478

79+
#### Rails 7 importmap based installation
80+
81+
{% content-ref url="js-via-importmap.md" %}
82+
[js-via-importmap.md](js-via-importmap.md)
83+
{% endcontent-ref %}
84+
8585
#### JSBundling-Rails based installation
8686

8787
{% content-ref url="js-via-jsbundling-rails.md" %}
@@ -138,6 +138,12 @@ Like documented here: [https://github.com/rails/cssbundling-rails](https://githu
138138
./bin/rails css:install:bootstrap
139139
```
140140

141+
And then add `matestack-ui-bootstrap`:
142+
143+
```bash
144+
yarn add matestack-ui-bootstrap
145+
```
146+
141147
Afterwards make sure your package.json looks something like that:
142148

143149
`package.json`
@@ -150,7 +156,8 @@ Afterwards make sure your package.json looks something like that:
150156
"@popperjs/core": "^2.11.5",
151157
"bootstrap": "^5.2.0-beta1",
152158
"bootstrap-icons": "^1.8.3",
153-
"sass": "^1.52.2"
159+
"sass": "^1.52.2",
160+
"matestack-ui-bootstrap": "^3.1.0"
154161
},
155162
"scripts": {
156163
"build:css": "sass ./app/assets/stylesheets/application.bootstrap.scss ./app/assets/builds/application.css --no-source-map --load-path=node_modules"
@@ -159,14 +166,20 @@ Afterwards make sure your package.json looks something like that:
159166

160167
```
161168

162-
Even if you use the importmap approach, this package.json will install the JavaScript packages into the node\_modules folder. They will not be used when following the importmap approach. Only the SCSS files will be used in this case.
169+
Even if you use the importmap approach, this package.json will install the JavaScript packages into the node\_modules folder. They will not be used when following the importmap approach. Only the (S)CSS files will be used in this case.
163170

164-
And finally add the `matestack-ui-bootstrap.css` file to your layout via CDN. Alternatively you can download this file and let it be served via Sprockets.
171+
And finally adjust the `app/assets/stylesheets/application.bootstrap.scss` to look like:
165172

166-
`app/views/layout.html.erb`
173+
```scss
174+
@import 'bootstrap/scss/bootstrap';
175+
@import 'matestack-ui-bootstrap/dist/matestack-ui-bootstrap';
167176

168-
```markup
169-
<link href="https://cdn.jsdelivr.net/npm/matestack-ui-bootstrap@3.1.0/dist/matestack-ui-bootstrap.css" rel="stylesheet" >
177+
```
178+
179+
and run your server and css builder with
180+
181+
```bash
182+
./bin/dev
170183
```
171184

172185
#### Option 2b : JSBundling-Rails + CSSBundling-Rails

docs/getting-started/installation-update/js-via-importmap.md

Lines changed: 0 additions & 57 deletions
Original file line numberDiff line numberDiff line change
@@ -39,61 +39,4 @@ MatestackUiBootstrap.registerComponents(appInstance) // add this
3939
document.addEventListener('DOMContentLoaded', () => {
4040
MatestackUiVueJs.mount(appInstance)
4141
})
42-
43-
```
44-
45-
### (S)CSS setup
46-
47-
#### Without cssbundling-rails
48-
49-
`app/views/layout.html.erb`
50-
51-
```markup
52-
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.2.0-beta1/dist/css/bootstrap.min.css" rel="stylesheet">
53-
<link href="https://cdn.jsdelivr.net/npm/matestack-ui-bootstrap@3.1.0/dist/matestack-ui-bootstrap.css" rel="stylesheet" >
54-
55-
<%= javascript_importmap_tags %>
5642
```
57-
58-
Please adjust the version numbers to your needs. They should match the JavaScript package versions used in the importmap config.
59-
60-
#### With cssbundling-rails
61-
62-
\--> In order to use SCSS features e.g. for Bootstrap theming&#x20;
63-
64-
(without jsbundling-rails, using importmap approach for JavaScript assets instead in this guide)
65-
66-
**Install cssbundling-rails**
67-
68-
Like documented here: [https://github.com/rails/cssbundling-rails](https://github.com/rails/cssbundling-rails)
69-
70-
```bash
71-
./bin/bundle add cssbundling-rails
72-
```
73-
74-
```bash
75-
./bin/rails css:install:bootstrap
76-
```
77-
78-
Afterwards make sure your package.json looks something like that:
79-
80-
`package.json`
81-
82-
```json
83-
{
84-
"name": "your-app",
85-
"private": "true",
86-
"dependencies": {
87-
"@popperjs/core": "^2.11.5",
88-
"bootstrap": "^5.2.0-beta1",
89-
"bootstrap-icons": "^1.8.3",
90-
"sass": "^1.52.2"
91-
},
92-
"scripts": {
93-
"build:css": "sass ./app/assets/stylesheets/application.bootstrap.scss ./app/assets/builds/application.css --no-source-map --load-path=node_modules"
94-
}
95-
}
96-
97-
```
98-
99-
This package.json will install all the JavaScript packages pinned via importmap config into the node\_modules folder. We just use the scss parts of it. Alternativel to the `importmap` approach, you could use `jsbundling-rails`
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,13 @@
11
# JS via JSBundling-Rails
22

3+
### Esbuild
4+
5+
currently not fully supported
6+
7+
### Rollup
8+
9+
not tested yet
10+
11+
### Webpack
12+
13+
not tested yet -> docs for [webpacker](js-via-webpacker.md) should be helpful for setting things up

0 commit comments

Comments
 (0)