0.1.0 • Published 5 years ago
@springernature/util-sass-compiler v0.1.0
SASS Compiler
Helper module for compiling SASS using node-sass, and returning the result as either CSS or JSON within a <Promise>. Used for testing SASS logic using Jest. 
Install
$ npm install @springernature/util-sass-compilerUsage
The render function returns an Object of the form
{
  "css": <Buffer>,
  "stats": {},
  "json": {}
}Example
Below is a simple example, see the test folder for more.
import {render} from '@springernature/util-sass-compiler';
describe('Compile Some SASS', () => {
  test('CSS String', async () => {
    const result = await render({
	  data: `
	    $size: 100px;
        .foo {
          width: $size;
        }`;
    });
    expect(result.css.toString().trim()).toEqual('.foo{width:100px}');
  });
  test('JSON match', async () => {
    const result = await render({
	  data: `
	    $size: 100px;
        .foo {
          width: $size;
        }`;
    });
    expect(result.json).toEqual(
      expect.objectContaining({
        '.foo': {
          'width': '100px'
        }
      })
    );
  });
});License
MIT License © 2020, Springer Nature
0.1.0
5 years ago