{"id":19219630,"url":"https://github.com/squirrel-forge/node-sass-base64-loader","last_synced_at":"2026-05-16T06:33:32.066Z","repository":{"id":57162160,"uuid":"451678676","full_name":"squirrel-forge/node-sass-base64-loader","owner":"squirrel-forge","description":"A node sass function for importing files as base64 encoded strings built for the new sass js api.","archived":false,"fork":false,"pushed_at":"2022-02-12T11:06:31.000Z","size":21,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-10-04T23:30:58.583Z","etag":null,"topics":["base64","base64-loader","loader","plugin","sass","sass-function"],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/squirrel-forge.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2022-01-25T00:16:51.000Z","updated_at":"2022-01-28T00:06:00.000Z","dependencies_parsed_at":"2022-09-09T07:01:25.614Z","dependency_job_id":null,"html_url":"https://github.com/squirrel-forge/node-sass-base64-loader","commit_stats":null,"previous_names":[],"tags_count":3,"template":false,"template_full_name":null,"purl":"pkg:github/squirrel-forge/node-sass-base64-loader","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/squirrel-forge%2Fnode-sass-base64-loader","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/squirrel-forge%2Fnode-sass-base64-loader/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/squirrel-forge%2Fnode-sass-base64-loader/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/squirrel-forge%2Fnode-sass-base64-loader/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/squirrel-forge","download_url":"https://codeload.github.com/squirrel-forge/node-sass-base64-loader/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/squirrel-forge%2Fnode-sass-base64-loader/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":33092688,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-16T04:41:52.686Z","status":"ssl_error","status_checked_at":"2026-05-16T04:41:52.009Z","response_time":115,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.5:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["base64","base64-loader","loader","plugin","sass","sass-function"],"created_at":"2024-11-09T14:32:18.953Z","updated_at":"2026-05-16T06:33:32.052Z","avatar_url":"https://github.com/squirrel-forge.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# @squirrel-forge/sass-base64-loader\nA node sass function for importing files as base64 encoded strings built for the new [sass js api](https://sass-lang.com/documentation/js-api) must be used with the new [sass](https://www.npmjs.com/package/sass) package.\nMade to be compatible with node ^10.0.0, might work on higher versions, but currently not supported or tested.\n\n## Installation\n\n```\nnpm i @squirrel-forge/sass-base64-loader\n```\n\n## Usage\n\n### Sass function\n\nSass function signature: ```base64load($source,$mimetype)```\n\n - **$source** : *string* - Url, absolute or relative path\n   (*Note:* Until sass context options are available, a relative path will be resolved relative to the *Base64loadOptions.cwd* option.)\n - **$mimetype** : *string* - The *$source* file's mimetype\n   (*Note:* This can be made optional by using the *Base64loadOptions.detect* or *Base64loadOptions.remote* option see [remote file loading and mime detection](#remote-file-loading-and-mimetype-detection) for details.)\n\n**Returns** : *quoted string* - Contains the given base64 encoded data uri  \n\n#### Source scss\n\n```scss\n:root {\n  --image-loading-gif: #{url(base64load('cwd/images/loading.gif','image/gif'))};\n}\n```\n\n#### Resulting css\n\n```css\n:root {\n  --image-loadgin-gif: url(\"data:image/gif;base64,R0lGODlhdgJ9AvYAAFZWVre3t0VFRdzc3DMzM...\");\n}\n```\n\n### Plugin usage:\n\n```javascript\nconst sass = require( 'sass' );\nconst base64Loader = require( '@squirrel-forge/sass-base64-loader' );\n\n// Classic way, calling the factory in place with options\nconst sassOptions = { functions : {} };\nsassOptions.functions[ base64Loader.signature ] = base64Loader( /* null|Base64loadOptions */ ).callback;\n\n// Destructuring the result object\nconst { signature, callback } = base64Loader( /* null|Base64loadOptions */ );\nsassOptions.functions[ signature ] = callback;\n\n// Plugin way, supply the sass options as second argument\n// It will create the functions property if required and add the signature and function.\nconst sassOptions = {};\nbase64Loader( /* null|Base64loadOptions */, sassOptions );\n\n// If not using the remote option you may use the sync compile which requires an explicit mimetype as second argument\nconst result = sass.compile( scssFilename, sassOptions );\n\n// OR when using the async api you may use the remote option and automatically detect mimetypes\nconst result = await sass.compileAsync( scssFilename, sassOptions );\n```\n\n#### Options\n\n```javascript\n/**\n * Base64load default options\n * @type {Object|Base64loadOptions}\n */\nconst BASE64LOAD_DEFAULT_OPTIONS = {\n    detect : false,\n    remote : false,\n    cwd : null,\n    cache : {},\n};\n\n/**\n * @typedef {Object} Base64loadOptions\n * @property {boolean} detect - Auto detect file mimetypes, default: false\n * @property {boolean} remote - Load files from http urls, default: false\n * @property {null|string} cwd - Base path for resolving relative paths, default: null \u003e process.cwd()\n * @property {null|Object|Base64loadStringCache} cache - Caching object, default: {}\n */\n```\n\n### Remote file loading and mimetype detection\n\nBoth options require use of the async *sass.compileAsync* api that supports async functions.\n\nIf you wish to load data from urls you need to set *Base64loadOptions.remote* = *true*\n\nTo automatically detect mimetypes set *Base64LoadOptions.detect* = *true*\n\n#### Requirements\n\nAll dependencies are loose and will only be required at runtime if required through the *Base64loadOptions.remote* or *Base64loadOptions.detect* option.\n\nRemote loading requires [node-fetch@^2.x.x](https://www.npmjs.com/package/node-fetch/v/2.6.7) to function in a *node@^10.x.x* environment, on higher node versions you should be able to use newer versions.\n\n#### Optional argument $mimetype\n\nThe *$mimetype* function argument becomes optional once you have enabled the *Base64loadOptions.detect* option or *Base64loadOptions.remote* loading and the async handler is used, but it requires [file-type@^16.x.x](https://www.npmjs.com/package/file-type/v/16.5.3) to function in a *node@^10.x.x* environment, on higher node versions you should be able to use newer versions.\n\n## Issues\n\nIf you encounter any issues, please report [here](https://github.com/squirrel-forge/node-sass-base64-loader/issues).\n\n---\nCheck the sourcecode on [github](https://github.com/squirrel-forge/node-sass-base64-loader) for extensive comments.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsquirrel-forge%2Fnode-sass-base64-loader","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsquirrel-forge%2Fnode-sass-base64-loader","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsquirrel-forge%2Fnode-sass-base64-loader/lists"}