How I implemented CSS Modules to Ruby on Rails, easily.

Fatih Kadir Akın
4 min readMay 28, 2016

Front-end has grown up. It is not easy to maintain front-end projects as we were doing in 2000’s. There are so many technologies, so many techniques and paradigms. Front-end is more responsible part of an application now. And when you develop a front-end included project, it may become hard to manage.

Smart people realise this issues and try to make the front-end more modular and more maintainable. One of these attempts is CSS Modules approach. This basically aims to separate CSS management into modules (as we are doing in JavaScript for a while).

Me and Adem are working in a Rails based project and it become slightly confusing b/c of the CSS parts. For sure, we are separating CSS files into files to make it manageable, but it’s not too easy to maintain HTML side then.

Modular and reusable CSS! — No more conflicts. — Explicit dependencies. — No global scope. (from CSS Modules)

I tried to find a cool way to integrate CSS Modules into our Rails project, but I cannot. So I decided to make my own.

Rails has awesome features that I still surprise when I learn about them. When I learn about I can write my own Sprockets Processors it made me feel powerful👌🏻

--

--