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: docs/css.md
+24-29
Original file line number
Diff line number
Diff line change
@@ -1,6 +1,5 @@
1
1
# CSS, Sass and SCSS
2
2
3
-
4
3
Webpacker supports importing CSS, Sass and SCSS files directly into your JavaScript files.
5
4
6
5
Importing and loading styles is a two step process:
@@ -15,7 +14,6 @@ Importing and loading styles is a two step process:
15
14
16
15
When you do `<%= stylesheet_pack_tag 'application' %>`, that's a run-time inclusion from Rails, where Rails gets the correct "asset path" to that file from webpack.
17
16
18
-
19
17
## Import global styles into your JS app
20
18
21
19
### Importing CSS as a multi-file pack (Webpacker v5)
@@ -60,7 +58,6 @@ Given your application installs an NPM package that provides CSS, such as `flatp
@@ -180,7 +177,6 @@ Then by adding these lines to your `package.json`:
180
177
181
178
You can generate the typings for the stylesheet by running the command `yarn gen-typings` when you've finished writing CSS, or run `yarn watch-typings` to have it automatically generate them as you go.
182
179
183
-
184
180
## Link styles from your Rails views
185
181
186
182
Under the hood webpack uses
@@ -192,8 +188,6 @@ a separate `[pack_name].css` bundle so that in your view you can use the
192
188
<%= stylesheet_pack_tag 'hello_react' %>
193
189
```
194
190
195
-
Webpacker emits css files only if `extract_css` is set to true in webpacker.yml otherwise `stylesheet_pack_tag` returns nil.
196
-
197
191
## Add bootstrap
198
192
199
193
You can use Yarn to add bootstrap or any other modules available on npm:
@@ -218,7 +212,6 @@ Or in your app/javascript/packs/application.sass file:
218
212
@import '~bootstrap/dist/css/bootstrap-theme'
219
213
```
220
214
221
-
222
215
## Post-Processing CSS
223
216
224
217
Webpacker out-of-the-box provides CSS post-processing using
@@ -244,8 +237,8 @@ module.exports = {
244
237
## Using CSS with [vue-loader](https://github.com/vuejs/vue-loader)
245
238
246
239
Vue templates require loading the stylesheet in your application in
247
-
order for CSS to work. This is in addition to loading the JavaScript
248
-
file for the entry point. Loading the stylesheet will also load the
240
+
order for CSS to work. This is in addition to loading the JavaScript
241
+
file for the entry point. Loading the stylesheet will also load the
249
242
CSS for any nested components.
250
243
251
244
```erb
@@ -257,7 +250,6 @@ CSS for any nested components.
257
250
258
251
Since `Sass/libsass` does not provide url rewriting, all linked assets must be relative to the output. Add the missing url rewriting using the resolve-url-loader. Place it directly after the sass-loader in the loader chain.
You may also use the package [typings-for-css-modules-loader](https://github.com/Jimdo/typings-for-css-modules-loader) instead of `css-loader` to automatically generate typescript `.d.ts` files in order to help resolve any css/scss styles. To do that:
0 commit comments