Use React Style CSS Modules in Your Rails App

October 13, 2020 / 5 min read

Rails

Step 1: add Rails.application.config.assets.precompile += %w( modules/my_css_module.css ) to config/initializers/assets.rbYou can add additional files separated by a space

Step 2: add <%= stylesheet_link_tag "modules/my_css_module.css" %> anywhere in the layout file or partial that is included in a layout file. Make sure that the file is also not present in application.css duplicate calls to assets will cause an error.

Step 3: Restart the server

Thanks for reading! 👋

Did you find this article useful?