SASS vs CSS Modules vs CSS-in-JS vs Compile time CSS-in-JS. Who wins?

This page summarizes the projects mentioned and recommended in the original post on dev.to

SaaSHub - Software Alternatives and Reviews
SaaSHub helps you find the best software and product alternatives
www.saashub.com
featured
  • vite

    Next generation frontend tooling. It's fast!

    And second problem, because all of our styles is just abstract global CSS we don't have a TypeScript support to check that our style really exist. And the resulting problem we don't have good IDE intelligence (especially if we have have additionalData that import of some files that contain SASS vars and mixins, in Webpack/Vite config). Yeah, we have solutions like:

  • SaaSHub

    SaaSHub - Software Alternatives and Reviews. SaaSHub helps you find the best software and product alternatives

    SaaSHub logo
  • typescript-plugin-css-modules

    A TypeScript language service plugin providing support for CSS Modules.

    But for VSCode we need setup TypeScript LS to use workspace version. For more information go here or here.

  • vite-plugin-sass-dts

    This is a plugin that automatically creates a type file when using the CSS module type-safely.

    Vite plugin sass dts that will generate TypeScript declarations for our CSS Modules.

  • css-modules-typescript-loader

    Webpack loader to create TypeScript declarations for CSS Modules

    Or for Webpack CSS Modules TypeScript loader

  • uap-core

    The regex file necessary to build language ports of Browserscope's user agent parser.

    import { css } from 'styled-components' // Works only on the client-side // For SSR we need have some Context to Provide User-Agent from request context to React application context const USER_AGENT = window.navigator.userAgent; // More details about browser detect regex // here - https://github.com/ua-parser/uap-core/blob/master/regexes.yaml export const checkIsIE10OrOlder = /MSIE /g.test(USER_AGENT); export const checkIsIE11 = /Trident\//g.test(USER_AGENT); export const checkIsEdge = /Edge\//g.test(USER_AGENT); export const checkIsFireFox = /Firefox\//gi.test(USER_AGENT); export const checkIsChrome = /Chrome\//gi.test(USER_AGENT); export const checkIsSafari = /Safari\//gi.test(USER_AGENT); export const checkIsYandex = /YaBrowser\//gi.test(USER_AGENT); export const styleIE11Browser = (...args) => checkIsIE11 ? css(...args) : null; export const styleEdgeBrowser = (...args) => checkIsEdge ? css(...args) : null; export const styleMicrosoftBrowsers = (...args) => checkIsIE11 || checkIsEdge || checkIsIE10OrOlder ? css(...args) : null; export const styleIsNotMicrosoftBrowsers = (...args) => !checkIsIE11 && !checkIsIE10OrOlder ? css(...args) : null; export const styleFireFoxBrowser = (...args) => checkIsFireFox ? css(...args) : null; export const styleSafariBrowser = (...args) => checkIsSafari ? css(...args) : null; export const styleYandexBrowser = (...args) => checkIsYandex ? css(...args) : null; export const browser = { ie: styleMicrosoftBrowsers, ie11: styleIE11Browser, edge: styleEdgeBrowser, notIE: styleIsNotMicrosoftBrowsers, firefox: styleFireFoxBrowser, moz: styleFireFoxBrowser, safari: styleSafariBrowser, yandex: styleYandexBrowser, };

  • linaria

    Zero-runtime CSS in JS library

    Linaria (Most popular, support React and Svelte)

  • vanilla-extract

    Zero-runtime Stylesheets-in-TypeScript

    Vanilla extract (very interesting, support more bundlers than Linaria)

  • compiled

    A familiar and performant compile time CSS-in-JS library for React.

    Compiled (Compile time CSS-in-JS solution from Atlassian)

  • razzle

    ✨ Create server-rendered universal JavaScript applications with no configuration

    Somehow at the interview I was asked "what i think about difficulty of configuring Webpack for Linaria, at that moment I realized, what to find a solution to set up Linaria with SSR is not simple task", but I will show you the final result for example Razzle config:

NOTE: The number of mentions on this list indicates mentions on common posts plus user suggested alternatives. Hence, a higher number means a more popular project.

Suggest a related project

Related posts

  • Individual css for every component?

    3 projects | /r/webdev | 14 Dec 2022
  • react-micro-styled: A small, fast, and simple CSS-in-JS solution for React.

    1 project | /r/react | 27 Nov 2022
  • react-micro-styled: A small, fast, and simple CSS-in-JS solution for React.

    1 project | /r/web_programming | 27 Nov 2022
  • react-micro-styled: A small, fast, and simple CSS-in-JS solution for React.

    1 project | /r/javascript | 26 Nov 2022
  • react-micro-styled: A small, fast, and simple CSS-in-JS solution for React.

    1 project | /r/Frontend | 26 Nov 2022

Did you konow that TypeScript is
the 1st most popular programming language
based on number of metions?