wizardpisces/tiny-sass-compiler
概要
Another sass compiler write from scatch,runnable on both node and browser
言語・ランタイムできること
- Extend/Inheritance
- Modules (@import and @use(which is more efficient than @import))
計測したスター増加
- 24時間
- 0
- 7日間
- 0
- 15日間
- 0
- 1か月
- 履歴を収集中
期間ごとの純増数です。期間は重複しており、日別の値ではありません。未計測の値は空欄です。スター数は注目度の指標であり、品質の保証ではありません。
README.md
オリジナルDescription
Another SASS compiler written from scratch, runnable both in node and browser environment
Target
This project(Not Production Ready) is for people who want to understand how to write a compiler; Basic Steps:
- SourceCode (SASS Scanning)
- TokenStream (Parsing)
- AST or Abstract Syntax Tree (Analysis)
- IR or Intermediate_representation
- HighLevelLanguage (CSS Code and SourceMap Generation)
Features:
- Variables
- Nesting
- Extend/Inheritance
- Operators
- Mixins
- Modules (@import and @use(which is more efficient than @import))
Installation
npm install --save tiny-sass-compiler
Usage in node
import sass from "tiny-sass-compiler";
//render API
sass.render({filename:'./default.scss'},(err,result)=>{
console.log(result.code)
})
// or renderSync
const result = sass.renderSync({filename:'./default.scss'})
console.log(result.code)
Usage in browser
import {compile} from 'tiny-sass-compiler/dist/tiny-sass-compiler.esm-browser.prod.js'
const result = compile(`
$font-stack: Helvetica, sans-serif;
$primary-color: #333;
body .test{
font: 100% $font-stack;
color: $primary-color;
}`)
console.log(result.code)
Terminal Setup
npm install -g tiny-sass-compiler
Command Line Interface
Support .scss extension for now
Usage
tiny-sass <input> [output]
The input and output must be a directory
Example
tiny-sass src/ dist/
will generate intermediate AST file in dist/ast and css file in dist/css
Test
Snapshot Test
Development
npm run test-source
Production
npm run test
will generate intermediate AST file in test-dist/ast and css file in test-dist/css
Example:
input:
$font-stack: Helvetica, sans-serif;
$primary-color: #333;
body .test{
font: 100% $font-stack;
color: $primary-color;
}
output:
CSS
body .test {
font: 100% Helvetica, sans-serif;
color: #333;
}
Jest test
npm run jest
Interested in more intermediate status? View files in ./test-dist/ which contains ast after parse+transform and dist code after codegen
Other Readme
Reference
関連プロジェクトを探す
読み込み中…