This repository was archived by the owner on Feb 23, 2021. It is now read-only.
File tree Expand file tree Collapse file tree 2 files changed +39
-2
lines changed Expand file tree Collapse file tree 2 files changed +39
-2
lines changed Original file line number Diff line number Diff line change 11const sass = require ( 'node-sass' ) ;
2- const path = require ( 'path ' ) ;
2+ const stripIndent = require ( 'strip-indent ' ) ;
33
44module . exports = ( css , settings ) => {
55 const cssWithPlaceholders = css
@@ -12,7 +12,10 @@ module.exports = (css, settings) => {
1212
1313 // Prepend option data to cssWithPlaceholders
1414 const optionData = settings . sassOptions && settings . sassOptions . data || "" ;
15- const data = optionData + "\n" + cssWithPlaceholders ;
15+ let data = optionData + "\n" + cssWithPlaceholders ;
16+
17+ // clean up extra indent if we are using indentedSyntax
18+ if ( settings . sassOptions && settings . sassOptions . indentedSyntax ) data = stripIndent ( data ) ;
1619
1720 const preprocessed = sass . renderSync (
1821 Object . assign (
Original file line number Diff line number Diff line change @@ -150,4 +150,38 @@ describe('styled-jsx-plugin-sass', () => {
150150 ` )
151151 )
152152 } )
153+
154+ it ( 'works with indentedSyntax' , ( ) => {
155+ assert . equal (
156+ plugin ( 'body\n\tdisplay: block\n\tmargin: 0' , {
157+ sassOptions : {
158+ indentedSyntax : true
159+ }
160+ } ) . trim ( ) ,
161+ cleanup ( `
162+ body {
163+ display: block;
164+ margin: 0; }
165+ ` )
166+ )
167+ } )
168+
169+ it ( 'cleans up extra indent with indentedSyntax' , ( ) => {
170+ assert . equal (
171+ plugin ( `
172+ body
173+ display: block
174+ margin: 0
175+ ` , {
176+ sassOptions : {
177+ indentedSyntax : true
178+ }
179+ } ) . trim ( ) ,
180+ cleanup ( `
181+ body {
182+ display: block;
183+ margin: 0; }
184+ ` )
185+ )
186+ } )
153187} )
You can’t perform that action at this time.
0 commit comments