How to use the emotion-utils.Stylis function in emotion-utils

To help you get started, we’ve selected a few emotion-utils examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github emotion-js / emotion / packages / babel-plugin-emotion / src / index.js View on Github external
import { touchSync } from 'touch'
import {
  getIdentifierName,
  getName,
  createRawStringFromTemplateLiteral,
  minify
} from './babel-utils'
import { hashString, Stylis } from 'emotion-utils'
import cssProps from './css-prop'
import ASTObject from './ast-object'

export function hashArray(arr) {
  return hashString(arr.join(''))
}

const staticStylis = new Stylis({ keyframe: false })

export function replaceCssWithCallExpression(
  path,
  identifier,
  state,
  t,
  staticCSSSrcCreator = src => src,
  removePath = false,
  staticCSSSelectorCreator = (name, hash) => `.${name}-${hash}`
) {
  try {
    const { hash, src } = createRawStringFromTemplateLiteral(path.node.quasi)
    const name = getName(getIdentifierName(path, t), 'css')

    if (state.extractStatic && !path.node.quasi.expressions.length) {
      const staticCSSRules = staticStylis(

emotion-utils

Shared utilities used by emotion, The Next Generation of CSS-in-JS.

MIT
Latest version published 7 years ago

Package Health Score

75 / 100
Full package analysis