Skip to content

Commit

Permalink
Add SASS/SCSS support
Browse files Browse the repository at this point in the history
Using `node-sass`.
Closes #3
  • Loading branch information
nemoDreamer committed Oct 1, 2018
1 parent d8ccd31 commit 27c196d
Show file tree
Hide file tree
Showing 4 changed files with 38 additions and 1 deletion.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ Or Settings/Preferences ➔ Packages ➔ Search for `preview`
- [x] [EmberScript](https://github.com/Glavin001/atom-preview/issues/39)
- [x] [ng-classify](https://github.com/Glavin001/atom-preview/issues/60)
- [x] [LiveScript](https://github.com/Glavin001/atom-preview/issues/89)
- [ ] [SASS](https://github.com/Glavin001/atom-preview/issues/3)
- [x] [SASS/SCSS](https://github.com/Glavin001/atom-preview/issues/3)
- [ ] [Markdown](https://github.com/Glavin001/atom-preview/issues/7)
- [ ] [Haml](https://github.com/Glavin001/atom-preview/issues/9)
- [ ] [ClojureScript](https://github.com/Glavin001/atom-preview/issues/15)
Expand Down
17 changes: 17 additions & 0 deletions lib/renderer.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -284,3 +284,20 @@ module.exports =
return cb null, e.message
exts: /\.(yaml)$/i
lang: -> 'json'
'SASS/SCSS':
render: (text, filepath, cb) ->
sass = require('node-sass')
sass.render(
{
file: filepath,
data: text,
outputStyle: 'expanded'
},
(error, result) ->
if error
cb null, error.message
else
cb null, String result.css
)
exts: /\.s[ac]ss$/i
lang: -> 'css'
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@
"livescript": "^1.4.0",
"loophole": "^1.0.0",
"ng-classify": "^4.0.2",
"node-sass": "^4.9.3",
"node-uuid": "^1.4.7",
"pug": "^2.0.0-alpha6",
"stylus": "^0.54.2",
Expand Down
19 changes: 19 additions & 0 deletions spec/samples/example.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
@mixin box($color:black) {
color: $color;

.box {
@content;
}
}

#container {
background-color: white;

@include box(#E0FF00) {
text-align: center;
};

.theme--dark & {
background-color: black;
}
}

0 comments on commit 27c196d

Please sign in to comment.