Skip to content
This repository was archived by the owner on Feb 23, 2021. It is now read-only.

Commit 1c0e9f9

Browse files
committed
fix: data option for indentedSyntax and variables
1 parent 2b39f81 commit 1c0e9f9

File tree

3 files changed

+23
-1
lines changed

3 files changed

+23
-1
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ This is a fixed/updated version of [styled-jsx-plugin-sass](https://github.com/g
77
## What's the difference?
88

99
This plugin works with [indented sass](#indented-syntax) and [dart sass](#dart-sass) too, neither of those were possible with the old package. It also includes code from pull requests that weren't merged in the original repo.
10+
1011
Credits to [@giuseppeg](https://github.com/giuseppeg), [@xhuz](https://github.com/xhuz) and [@jamestalmage](https://github.com/jamestalmage).
1112

1213
## Usage

index.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,8 @@ module.exports = (css, settings) => {
1919
// Prepend option data to cssWithPlaceholders
2020
const optionData = settings.sassOptions && settings.sassOptions.data || ''
2121
// clean up extra indent (indentedSyntax is not compatible with extra indenting)
22-
let data = stripIndent(optionData + '\n' + cssWithPlaceholders)
22+
// they need to be cleaned up separately, and than concated
23+
const data = stripIndent(optionData) + '\n' + stripIndent(cssWithPlaceholders)
2324

2425
const preprocessed = sass
2526
.renderSync(Object.assign({}, settings.sassOptions, { data }))

test.js

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -185,4 +185,24 @@ describe('styled-jsx-plugin-sass', () => {
185185
`)
186186
)
187187
})
188+
189+
it('works with data option', () => {
190+
assert.equal(
191+
plugin(`
192+
div
193+
display: block
194+
color: $test-color
195+
`, {
196+
sassOptions: {
197+
indentedSyntax: true,
198+
data: `$test-color: #ff0000`
199+
}
200+
}).trim(),
201+
cleanup(`
202+
div {
203+
display: block;
204+
color: #ff0000; }
205+
`)
206+
)
207+
})
188208
})

0 commit comments

Comments
 (0)