DEV Community

Cover image for Migration CSS modules to vanilla-extract
j1ngzoue
j1ngzoue

Posted on • Edited on

4 4

Migration CSS modules to vanilla-extract

Introduction

We have created a tool to generate typescript files for vanilla-extract, a Zero-runtime Stylesheets, from css (scss/sass) style definitions.
https://github.com/activeguild/css-to-vanilla-extract

The tools described here can be tried in the playground.

The following APIs are covered.

Motivation

  • Convert style definitions received from designers without any errors.
  • Cost-effective migration of existing projects using css modules.

e.g.

input

.foo {
  background-color: blue;
}
@media (min-width: 1200px) {
  .foo {
    font-size: 5rem;
    color: red;
  }
}
Enter fullscreen mode Exit fullscreen mode

output

import { style } from "@vanilla-extract/css";
export const foo = style({
  backgroundColor: "blue",
  "@media": {
    "(min-width: 1200px)": {
      color: "red",
      fontSize: "5rem",
    },
  },
});
Enter fullscreen mode Exit fullscreen mode

This tool was created on a trial basis.I think css modules and other css can be converted with little or no problem.

Top comments (0)

Image of Docusign

🛠️ Bring your solution into Docusign. Reach over 1.6M customers.

Docusign is now extensible. Overcome challenges with disconnected products and inaccessible data by bringing your solutions into Docusign and publishing to 1.6M customers in the App Center.

Learn more