Skip to content

Commit

Permalink
Merge pull request rails#41226 from t27duck/missing_erb_in_webpacker_…
Browse files Browse the repository at this point in the history
…guide

Guides: Missing erb tags for stylesheet_pack_tag [ci skip]
  • Loading branch information
gmcgibbon authored Jan 25, 2021
2 parents cdcee5c + a131b7f commit 6143b11
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion guides/source/webpacker.md
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ Within source files, `import` statements are resolved relative to the file doing

Out of the box, Webpacker supports CSS and SCSS using the PostCSS processor.

To include CSS code in your packs, first include your CSS files in your top-level pack file as though it was a JavaScript file. So if your CSS top-level manifest is in `app/javascript/styles/styles.scss`, you can import it with `import styles/styles`. This tells webpack to include your CSS file in the download. To actually load it in the page, you need to include a `<stylesheet_pack_tag "application">`, where the `application` is the same pack name that you were using. (Note, the docs still say you need to use `stylesheet_pack_tag`, but experimenting suggests that the CSS will load without it.)
To include CSS code in your packs, first include your CSS files in your top-level pack file as though it was a JavaScript file. So if your CSS top-level manifest is in `app/javascript/styles/styles.scss`, you can import it with `import styles/styles`. This tells webpack to include your CSS file in the download. To actually load it in the page, include `<%= stylesheet_pack_tag "application" %>` in the view, where the `application` is the same pack name that you were using.

If you are using a CSS framework, you can add it to Webpacker by following the instructions to load the framework as an NPM module using `yarn`, typically `yarn add <framework>`. The framework should have instructions on importing it into a CSS or SCSS file.

Expand Down

0 comments on commit 6143b11

Please sign in to comment.