{"id":29108531,"url":"https://github.com/milichev/sass-all-variable-loader","last_synced_at":"2026-05-07T02:34:07.941Z","repository":{"id":45318040,"uuid":"124948060","full_name":"milichev/sass-all-variable-loader","owner":"milichev","description":"Loads sass files and extracts all variable declarations including from the imported sass files","archived":false,"fork":false,"pushed_at":"2018-05-21T21:20:56.000Z","size":25,"stargazers_count":0,"open_issues_count":3,"forks_count":2,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-06-13T00:45:30.216Z","etag":null,"topics":["json","loader","sass","scss","variables","webpack"],"latest_commit_sha":null,"homepage":null,"language":"TypeScript","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/milichev.png","metadata":{"files":{"readme":"README.md","changelog":null,"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":"2018-03-12T20:34:17.000Z","updated_at":"2018-03-14T14:07:28.000Z","dependencies_parsed_at":"2022-09-10T02:10:35.602Z","dependency_job_id":null,"html_url":"https://github.com/milichev/sass-all-variable-loader","commit_stats":null,"previous_names":[],"tags_count":5,"template":false,"template_full_name":null,"purl":"pkg:github/milichev/sass-all-variable-loader","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/milichev%2Fsass-all-variable-loader","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/milichev%2Fsass-all-variable-loader/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/milichev%2Fsass-all-variable-loader/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/milichev%2Fsass-all-variable-loader/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/milichev","download_url":"https://codeload.github.com/milichev/sass-all-variable-loader/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/milichev%2Fsass-all-variable-loader/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":261576948,"owners_count":23179724,"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":["json","loader","sass","scss","variables","webpack"],"created_at":"2025-06-29T06:11:36.527Z","updated_at":"2026-05-07T02:34:02.922Z","avatar_url":"https://github.com/milichev.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# sass-all-variable-loader\n\n\u003e Loads sass files and extracts all variable declarations including\nfrom the imported sass files.\n\n[![npm version](https://badge.fury.io/js/sass-all-variable-loader.svg)](https://badge.fury.io/js/sass-all-variable-loader) [![dependencies](https://david-dm.org/milichev/sass-all-variable-loader.svg)](https://david-dm.org/milichev/sass-all-variable-loader) [![devDependecies](https://david-dm.org/milichev/sass-all-variable-loader/dev-status.svg)](https://david-dm.org/milichev/sass-all-variable-loader#info=devDependencies)\n\n## About\n\nThis webpack loader helps to get variable values from the SASS file\nin the JavaScript file as a JSON object with the property names\ncorresponding to variable names.\n\n## Installation\n\n### npm\n\n```\n$ npm install --save-dev sass-all-variable-loader\n```\n\n### yarn\n\n```\n$ yarn add sass-all-variable-loader -D\n```\n\n## Usage\n\nIt's better to create a SASS file which imports all variable declaration\nfiles you need. For example, `variables.scss`:\n\n```\n@import \"./common-variables\";\n@import \"./bootstrap-variables\";\n@import \"~bootstrap/scss/functions\";\n@import \"~bootstrap/scss/variables\";\n```\n\nSuppose _bootstrap-variables.scss_ declares variables as follows:\n\n```\n$gray-800: #29363d;\n\n$body-color: $gray-800;\n```\n\nThen declare a loader in your **webpack config**:\n\n```\nmodule.exports = {\n  module: {\n    rules: [\n      {\n        oneOf: [\n          {\n            test: /variables\\.scss/,\n            use: [\n              'sass-all-variable-loader',\n            ]\n          },\n```\n\n**Important thing: this entry should be _before_ any other .scss loaders.**\n\nThen you can import variables in your .js/.ts file:\n\n```\nimport * as reactstrap from 'reactstrap';\nimport styled from 'styled-components';\n\nconst variables = require('../../scss/variables.scss');\n\nexport const Pimpochka = styled(reactstrap.Button)`\n  background-color: ${variables['$body-color']};\n`;\n```\n\nIf you don't want to declare a separate entry in webpack config, you\ncan import the sass file with the exclamation mark syntax:\n\n```\nimport variables from '!!sass-all-variable-loader!./_variables.scss';\n```\n\nHowever I don't recommend it because it is weird and it breaks\nnavigation in your favorite IDE.\n\n## Limitations\n\nThis loader was created because of critical limitations of similar ones\nout there. For example\n[sass-variable-loader](https://github.com/nordnet/sass-variable-loader)\ncan't handle any multiline statements or declarations such as sass maps\nor functions. Even though this loader still has it's own limitations:\n\n* The current implementation neglects the content from the previous\nloaders, if any.\n* The resulting map preserves the variable names (see usage example\nabove). If you need them _camelCased_, you are welcome to contribute.\n\n## License\n\n[MIT](LICENSE)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmilichev%2Fsass-all-variable-loader","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmilichev%2Fsass-all-variable-loader","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmilichev%2Fsass-all-variable-loader/lists"}