{"id":15041666,"url":"https://github.com/lassehaslev/sass-asset-inliner","last_synced_at":"2026-02-23T23:13:34.853Z","repository":{"id":57126316,"uuid":"88963123","full_name":"LasseHaslev/sass-asset-inliner","owner":"LasseHaslev","description":"Sass functions for base64 encode files and assets through local path or url.","archived":false,"fork":false,"pushed_at":"2017-09-02T08:05:08.000Z","size":146,"stargazers_count":1,"open_issues_count":1,"forks_count":1,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-02-01T14:45:08.549Z","etag":null,"topics":["base64","encoding","functions","inline-assets","node-sass","sass","sass-asset-inliner"],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/LasseHaslev.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2017-04-21T08:49:49.000Z","updated_at":"2023-03-05T01:46:03.000Z","dependencies_parsed_at":"2022-08-31T12:10:39.292Z","dependency_job_id":null,"html_url":"https://github.com/LasseHaslev/sass-asset-inliner","commit_stats":null,"previous_names":[],"tags_count":6,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/LasseHaslev%2Fsass-asset-inliner","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/LasseHaslev%2Fsass-asset-inliner/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/LasseHaslev%2Fsass-asset-inliner/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/LasseHaslev%2Fsass-asset-inliner/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/LasseHaslev","download_url":"https://codeload.github.com/LasseHaslev/sass-asset-inliner/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":245822303,"owners_count":20678165,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","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","encoding","functions","inline-assets","node-sass","sass","sass-asset-inliner"],"created_at":"2024-09-24T20:46:21.060Z","updated_at":"2026-02-23T23:13:34.821Z","avatar_url":"https://github.com/LasseHaslev.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# @lassehaslev/sass-asset-inliner\n\u003e Helper functions for node-sass for inlining / base64 encoding assets\n\n## Install\n```bash\nnpm install @lassehaslev/sass-asset-inliner --save\n```\n\n## Usage\n\n### Setup\n\nYou need to add the `sass-asset-inliner` functions to `node-sass` `function option`.\n\n```js\nvar sass = require('node-sass');\n\n// When not using es6 you must use the default property\nvar SassAssetInliner = require( '@lassehaslev/sass-asset-inliner' ).default;\n\nsass.render({\n    file: scss_filename,\n    {\n        functions: SassAssetInliner,\n    }\n}, function(err, result) { /*...*/ });\n```\n\n### Sass\n\nInline assets by including `absolute path`, `relative path` or `url` to the assets you want to inline.\n\n#### Inline images\n```scss\nbody {\n    // Inline image\n    background-image: inline-image( 'path/to/your/image.png' );\n\n    // Inline and resize image to width (Kepp aspect ratio)\n    background-image: inline-image( 'path/to/your/image.png', \"200\" );\n\n    // Resize image and ignoring aspect ratio\n    background-image: inline-image( 'path/to/your/image.png', \"200x400\" );\n\n    // Resize image to height and keep aspect ratio\n    background-image: inline-image( 'path/to/your/image.png', \"_x400\" );\n\n    // Underscore works also for height.\n    // (\"200x_\" equals \"200\" as shown above)\n}\n```\n\n#### Inline fonts\n\n\u003e Note: at this point, there is not possible to subset a font from a url.\n\n```scss\n@font-face {\n    src: inline-font( 'path/to/your/font.ttf' ); // Include full font\n\n    // Subset font by adding regex as second parameter\n    // of each character you want to include\n    src: inline-font( 'path/to/your/font.ttf', '[0-9]' );\n}\n```\n\n### Api\n\nAs the [SassFunctions](https://github.com/LasseHaslev/sass-asset-inliner/blob/development/src/SassFunctions.js) you can use the functions of the [Encoder](https://github.com/LasseHaslev/sass-asset-inliner/blob/development/src/Encoder.js).\n\n```js\nimport {Encoder} from '@lassehaslev/sass-asset-inliner';\n\n// base64 encode file\nEncoder.encode( '{path}' );\n\n// base64 encode image\nEncoder.encodeImage( '{path}', '100x100' );\n\n// base64 encode font\nEncoder.encodeFont( '{path}', '[0-9]' );\n```\n\n### Development\n\n```bash\n// Test driven development\nnpm run tdd\n\n// Build\nnpm run build\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flassehaslev%2Fsass-asset-inliner","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Flassehaslev%2Fsass-asset-inliner","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flassehaslev%2Fsass-asset-inliner/lists"}