mirror of
https://github.com/nostalgic-css/NES.css.git
synced 2025-05-06 22:05:29 +02:00
I’ve added a SCSS function that, when passed a file path, will inject the file as a data URI. This is super helpful since it ensures that the cursor images will always be available for the CSS. This issue currently prevents the npm version of the library from being usable at all.
16 lines
467 B
JavaScript
16 lines
467 B
JavaScript
/* eslint-disable import/no-extraneous-dependencies */
|
|
const filetype = require('file-type');
|
|
const fs = require('fs');
|
|
const path = require('path');
|
|
/* eslint-enable */
|
|
|
|
module.exports = (fileString) => {
|
|
const filepath = path.resolve(__dirname, fileString.getValue());
|
|
const fileBuffer = fs.readFileSync(filepath);
|
|
|
|
const fileDataURI = fileBuffer.toString('base64');
|
|
const { mime } = filetype(fileBuffer);
|
|
|
|
return `data:${mime};base64,${fileDataURI}`;
|
|
};
|