Skip to main content

Developing v2

One of the main goals of this project remains bringing an API to Sass that complements JavaScript. Great strides toward that end have already been achieved in Sass Fairy v1, but there are still some areas where differences exist. During development of v2 hopefully that gap can close even further.

One difference is that Sass Fairy’s string.replace() function does not accept regular expressions. CSS even doesn’t have regular expressions, but I’m gonna sure try to add them.

Other current deficiencies in Sass Fairy are hacky solutions. Take for instance the string.is-quoted() function:

@sass-fairy/string/src/_is-quoted.sass
@function is-quoted($string)

@if meta.type-of($string) != 'string'
@error exception.parameter-type('is-quoted', 'string', $string, 'string')

@return meta.inspect($string) != $string

Comparing meta.inspect() is hardly intuitive or in spec.

What is actually changing

Sass has begun exposing a JavaScript API enabling direct access to the features of JavaScript Sass Fairy is trying complement.

Migrating from v1

caution

Version 2 is still under heavy development and is not yet ready for use in production.

First and foremost, each Sass Fairy v2 package now exports a JavaScript API. These are functions that Sass needs to know about in order to compile stylesheets using Sass Fairy.

Simply update your Sass compiler to include them:

sass.compile(filePath, {
// ...
functions: {
...require('@sass-fairy/list'),
...require('@sass-fairy/break')
}
});

Expect the Sass Fairy API to have changed between v1 and v2. Primarily these changes are going to be new features and expansions to the API of v1.