Gathering detailed insights and metrics for sass-export-extend
Gathering detailed insights and metrics for sass-export-extend
Gathering detailed insights and metrics for sass-export-extend
Gathering detailed insights and metrics for sass-export-extend
npm install sass-export-extend
Typescript
Module System
Min. Node Version
Node Version
NPM Version
TypeScript (87.15%)
SCSS (10.46%)
JavaScript (2.39%)
Total Downloads
0
Last Day
0
Last Week
0
Last Month
0
Last Year
0
MIT License
150 Commits
1 Watchers
2 Branches
13 Contributors
Updated on Nov 25, 2021
Latest Version
1.0.4
Package Id
sass-export-extend@1.0.4
Unpacked Size
42.30 kB
Size
12.02 kB
File Count
32
NPM Version
6.14.15
Node Version
14.18.2
Cumulative downloads
Total Downloads
Last Day
0%
NaN
Compared to previous day
Last Week
0%
NaN
Compared to previous week
Last Month
0%
NaN
Compared to previous month
Last Year
0%
NaN
Compared to previous year
Sass-export takes SCSS files and export them to a JSON file you can use as data. This is perfect for generating your site documentation.
Install it from NPM
1 npm install -g sass-export
Ready to export:
1 sass-export scss/config/*.scss -o exported-sass-array.json -a
input: _variables.css
1 $gray-medium: #757575;/*@sass-export-group="主色" @sass-export-commet="品牌色"*/ 2 $base-value: 25px; 3 $gray-dark: darken($gray-medium, 5%); 4 $logo: url(logo.svg); 5 $logo-quotes: url('logo.svg'); 6 $calculation: $base-value - 12px; 7 $multiple-calculations: $base-value - floor(12.5px);
output: exported-sass-array.json
1[ 2 { "name": "$gray-medium", "value": "#757575", "compiledValue": "#757575", "extend_group": "主色", 3 "extend_commet": "品牌色" }, 4 { "name": "$base-value", "value": "25px", "compiledValue": "25px" }, 5 { "name": "$gray-dark", "value": "darken($gray-medium, 5%)", "compiledValue" :"#686868" }, 6 { "name": "$logo", "value": "url(logo.svg)", "compiledValue": "url(logo.svg)" }, 7 { "name": "$logo-quotes", "value": "url('logo.svg')", "compiledValue": "url(\"logo.svg\")" }, 8 { "name": "$calculation", "value": "$base-value - 12px", "compiledValue": "13px" }, 9 { "name": "$multiple-calculations", "value": "$base-value - floor(12.5px)", "compiledValue": "13px" } 10]
You can easily organize your variables into a Javascript object using sass-export annotations:
input: _annotations.scss
1$black: #000; 2$slate: #8ca5af; 3 4/** 5 * @sass-export-section="brand-colors" 6 */ 7$brand-gray-light: #eceff1; 8$brand-gray-medium: #d6d6d6; 9$brand-gray: #b0bec5; 10//@end-sass-export-section [optional] 11 12/** 13 * @sass-export-section="fonts" 14 */ 15$font-size: 16px; 16$font-color: $brand-gray-medium; 17//@end-sass-export-section 18 19$global-group: #FF0000;
Then we run sass-export:
1 sass-export scss/_annotations.scss -o exported-grouped.json
output exported-grouped.json
1{ 2 "variables": [ 3 { "name": "$black", "value": "#000", "compiledValue": "#000" }, 4 { "name": "$slate", "value": "#8ca5af", "compiledValue": "#8ca5af" }, 5 { "name": "$global-group", "value": "#ff0000", "compiledValue": "#ff0000" } 6 ], 7 "brand-colors": [ 8 { "name": "$brand-gray-light", "value": "#eceff1", "compiledValue":"#eceff1" }, 9 { "name": "$brand-gray-medium", "value": "#d6d6d6" ,"compiledValue":"#d6d6d6" }, 10 { "name": "$brand-gray", "value": "#b0bec5", "compiledValue": "#b0bec5" } 11 ], 12 "fonts": [ 13 { "name": "$font-size", "value": "16px", "compiledValue": "16px" }, 14 { "name": "$font-color", "value": "$brand-gray-medium", "compiledValue":"#d6d6d6" } 15 ] 16}
In order to support @import we need to include --dependencies parameter with a comma separated list of the folder path to include:
1sass-export scss/_fonts.scss -o=exported-dependencies.json -d "src/sass/config/, src/sass/libs/"
in order to use:
1@import "breakpoints"; 2@import "variables"; 3 4$imported-value: $bp-desktop; 5$font-size: $global-font-size;
In case you wanted your sass Maps variable to be an array we included te mapValue property for variables identified as maps.
input: _breakpoints.scss
1$breakpoints: ( 2 small: 767px,/*@sass-export-screen="mini屏"*/ 3 medium: 992px, 4 large: 1200px 5);
output: exported-maps.json
1{ 2 "variables": [ 3 { 4 "name": "$breakpoints", 5 "value": "(small: 767px, medium: 992px, large: 1200px)", 6 "mapValue": [ 7 { "name": "small", "value": "767px", "compiledValue": "767px", "extend_screen": "mini屏" }, 8 { "name": "medium","value": "992px", "compiledValue": "992px" }, 9 { "name": "large", "value": "1200px", "compiledValue": "1200px" } 10 ], 11 "compiledValue": "(small:767px,medium:992px,large:1200px)" 12 } 13}
For mixins and functions we've added a reserved 'mixins' group for it.
input: _mixins.scss
1@mixin box($p1, $p2) { 2 @content; 3} 4 5@function my-function($val) { 6} 7 8@mixin z($val: 10px, $p2: '#COFF33') { 9 @content; 10} 11 12@mixin no-params() { 13}
output: exported-mixins.json
1{ 2 "mixins": [ 3 { 4 "name": "box", 5 "parameters": [ "$p1", "$p2" ] 6 }, 7 { 8 "name": "my-fucntion", 9 "parameters": [ "$val" ] 10 }, 11 { 12 "name": "z", 13 "parameters": [ "$val: 10px", "$p2: '#COFF33'" ] 14 }, 15 { 16 "name": "no-params", 17 "parameters": [] 18 } 19 ] 20}
import syntax:
1 import { exporter } from 'sass-export';
Require syntax:
1const exporter = require('sass-export').exporter; 2 3const exporterBuffer = require('sass-export').buffer;
Written using ES5 syntax.
1 2const exporter = require('sass-export').exporter; 3 4//basic options 5const options = { 6 inputFiles: ['_variables.scss', '_fonts.scss'], 7 includePaths: ['libs/'] // don't forget this is the folder path not the files 8}; 9 10// you can get an object {variables:[], colors: []} 11const asObject = exporter(options).getStructured(); 12 13console.log(asObject.variables); 14console.log(asObject.colors); 15 16// or get an array [{}, {}] 17const asArray = exporter(options).getArray(); 18 19console.log(asArray)
Usage: sass-export [inputFiles] [options]
Options | Type | Description |
---|---|---|
-o, --output | String | File path where to save the JSON exported. |
-a, --array | Boolean | If it is present, it will output an array file instead of a object structured. |
-d, --dependencies | String[] | List of dependencies separated by comma, where Sass will try to find the @imports that your inputFiles need to work. Example: "libs/, config/, variables/". |
-h, --help | Boolean | Shows up this help screen. |
Please feel free to submit pull requests or open issues to improve this tool. Also keep checking issues section and grab some items to help!
Check our Contributing page for more information.
License
MIT
This is an open source project and completely free to use.
However, the amount of effort needed to maintain and develop new features and products within the Plentycode ecosystem is not sustainable without proper financial backing. If you have the capability, please consider donating using the link below:
No vulnerabilities found.
No security vulnerabilities found.