{"id":13672767,"url":"https://github.com/wizardpisces/tiny-sass-compiler","last_synced_at":"2025-04-04T11:17:10.350Z","repository":{"id":42700570,"uuid":"247049147","full_name":"wizardpisces/tiny-sass-compiler","owner":"wizardpisces","description":"Another sass compiler write from scatch，runnable on both node and browser","archived":false,"fork":false,"pushed_at":"2024-09-27T06:03:40.000Z","size":1440,"stargazers_count":289,"open_issues_count":4,"forks_count":9,"subscribers_count":4,"default_branch":"master","last_synced_at":"2025-03-28T21:04:08.562Z","etag":null,"topics":["cli","compiler","lexical-analyzer","parser","sass","superstruct","typescript"],"latest_commit_sha":null,"homepage":"","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/wizardpisces.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,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2020-03-13T10:50:06.000Z","updated_at":"2025-03-06T15:52:45.000Z","dependencies_parsed_at":"2024-10-29T14:23:30.826Z","dependency_job_id":null,"html_url":"https://github.com/wizardpisces/tiny-sass-compiler","commit_stats":{"total_commits":176,"total_committers":2,"mean_commits":88.0,"dds":0.09659090909090906,"last_synced_commit":"ddcd827b2dd16f504b05f0411c938e8bb5a5e5cf"},"previous_names":[],"tags_count":25,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wizardpisces%2Ftiny-sass-compiler","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wizardpisces%2Ftiny-sass-compiler/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wizardpisces%2Ftiny-sass-compiler/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wizardpisces%2Ftiny-sass-compiler/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/wizardpisces","download_url":"https://codeload.github.com/wizardpisces/tiny-sass-compiler/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247166171,"owners_count":20894654,"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":["cli","compiler","lexical-analyzer","parser","sass","superstruct","typescript"],"created_at":"2024-08-02T09:01:47.111Z","updated_at":"2025-04-04T11:17:10.299Z","avatar_url":"https://github.com/wizardpisces.png","language":"TypeScript","funding_links":[],"categories":["TypeScript"],"sub_categories":[],"readme":"## Description \n\nAnother SASS compiler written from scratch, runnable both in ***node*** and ***browser*** environment\n\n[Demo](https://wizardpisces.github.io/sass)\n\n## Target\nThis project(**Not Production Ready**) is for people who want to understand how to write a compiler; Basic Steps:\n\n1. SourceCode (SASS Scanning)  \n2. TokenStream (Parsing) \n3. [AST or Abstract Syntax Tree](https://en.wikipedia.org/wiki/Abstract_syntax_tree) (Analysis) \n4. [IR or Intermediate_representation](https://en.wikipedia.org/wiki/Intermediate_representation)\n5. HighLevelLanguage (CSS Code and SourceMap Generation)\n\n## Features:\n\n1. Variables\n2. Nesting\n3. Extend/Inheritance\n4. Operators\n5. Mixins\n6. Modules ([@import](https://sass-lang.com/documentation/at-rules/import) and [@use](https://sass-lang.com/documentation/at-rules/use)(which is more efficient than @import))\n\n## Installation\n\n```bash\nnpm install --save tiny-sass-compiler\n```\n\n### Usage in node\n\n```ts\nimport sass from \"tiny-sass-compiler\";\n\n//render API\nsass.render({filename:'./default.scss'},(err,result)=\u003e{\n  console.log(result.code)\n})\n// or renderSync\nconst result = sass.renderSync({filename:'./default.scss'})\nconsole.log(result.code)\n```\n\n### Usage in browser\n\n```ts\nimport {compile} from  'tiny-sass-compiler/dist/tiny-sass-compiler.esm-browser.prod.js'\nconst result = compile(`\n$font-stack:    Helvetica, sans-serif;\n$primary-color: #333;\n\nbody .test{\n  font: 100% $font-stack;\n  color: $primary-color;\n}`)\n\nconsole.log(result.code)\n```\n\n## Terminal Setup\n\n```bash\nnpm install -g tiny-sass-compiler\n```\n\n### Command Line Interface\n\n*Support **.scss** extension for now*\n\n### Usage\n\n\n`tiny-sass \u003cinput\u003e [output]`\n\nThe `input` and `output` must be a directory\n\nExample\n\n```bash\ntiny-sass src/ dist/\n```\n\n*will generate intermediate AST file in dist/ast and css file in dist/css*\n\n## Test\n\n### Snapshot Test\n**Development**\n```bash\nnpm run test-source\n```\n**Production**\n```bash\nnpm run test\n```\n*will generate intermediate AST file in test-dist/ast and css file in test-dist/css*\n\n### Example:\n\n#### input:\n\n```scss\n$font-stack:    Helvetica, sans-serif;\n$primary-color: #333;\n\nbody .test{\n  font: 100% $font-stack;\n  color: $primary-color;\n}\n```\n#### output:\n\nCSS\n```css\nbody .test {\n    font: 100% Helvetica, sans-serif;\n    color: #333;\n}\n```\n\n### Jest test\n\n```bash\nnpm run jest\n```\n\n*Interested in more intermediate status? View files in ./test-dist/ which contains ast after parse+transform and dist code after codegen*\n\n## Other Readme\n\n* [AST Descriptor Syntax](https://github.com/wizardpisces/tiny-sass-compiler/blob/master/src/parse/ast.ts)\n* [AST travesal Plugin](https://github.com/wizardpisces/tiny-sass-compiler/blob/master/traversal.md)\n* [AST Interpret Transform Plugin](https://github.com/wizardpisces/tiny-sass-compiler/blob/master/transform.md)\n\n## Reference\n\n* [csstree](https://github.com/csstree/csstree)\n* [astexplorer](https://astexplorer.net/#/gist/244e2fb4da940df52bf0f4b94277db44/e79aff44611020b22cfd9708f3a99ce09b7d67a8)\n* [vue-next/compiler-core](https://github.com/vuejs/vue-next/tree/master/packages/compiler-core)\n* [lisperator](http://lisperator.net/pltut/)\n* [less](https://less.bootcss.com/features/#plugin-at-rules)\n* [hast](https://github.com/syntax-tree/hast)\n* [unist](https://github.com/syntax-tree/unist)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwizardpisces%2Ftiny-sass-compiler","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fwizardpisces%2Ftiny-sass-compiler","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwizardpisces%2Ftiny-sass-compiler/lists"}