Sass eyeglass module for getting the contents of text or binary files as (encoded) string.
New: Supports binary files now (encodes to base64).
New: Normalizes line endings to prevent issues with quotes and later output of the string.
npm install --save-dev eyeglass-file-text
@import 'file-text';
// Fetch text file:
$text : file-text('./loremipsum.txt');
// encoding can be explicitly specified by 2nd argument
// Fetch binary file:
$base64: file-binary('./test.jpg');
// binary file content is represented as base64 text
// The string can then be used as usual in sass:
.test-text {
content: $text;
}
.test-binary {
background: url("data:image/jpeg;base64,#{$base64}");
}
Path to the file.
Encoding of the file. Defaults to utf8.
Path to the file.