GithubHelp home page GithubHelp logo

cssbuild's Introduction

cssbuild

A fast CSS compiler supporting a limited subset of CSS modules functionality.

Features

  • Generated class selectors and animation names are suffixed with a random token to effectively make them locally scoped by default
  • Local scoping can be switched off via a :global mode selector or :global() function
  • Generates JS files with class name and animation name mappings

What's not supported

  • Local @import and @url
  • Class composition

Installation

go get -u github.com/bduffany/cssbuild

Running

# Convert a CSS module stylesheet to vanilla CSS.
cssbuild -in src/styles.module.css -out dist/styles.css

# The above command writes JS to `dist/styles.module.css.js`.
# You can control this with the `-js_out` flag:
cssbuild -in src/styles.module.css -out dist/styles.css -js_out dist/styles.js

# See all options with documentation:
cssbuild -help

More details

  • The map keys in the generated JS file can optionally be made camelCase, using the -camel_case_js_keys flag, even if class names are kebab-case. This makes it easier to migrate to CSS modules (no need to waste time rewriting existing CSS or break with convention by requiring all CSS classes to be camelCase).
  • The :global mode selector applies to the rules block, which allows referencing global animation names.
  • Animation scoping supports -webkit- and -moz- prefixes.

Thanks to

  • tdewolff/parse for the excellent CSS parsing library, which made it possible to implement this with minimal custom parsing.
  • evanw/esbuild for inspiration.

cssbuild's People

Contributors

bduffany avatar

Stargazers

 avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.