Skip to content

Commit 9f58df2

Browse files
committed
Fix: relative paths in @import statements don't work.
Previous attempts to allow relative paths in @import statements added to `sassOptions.includePaths`. That was deemed unacceptable as it would capture relative files that weren't explicitly imported with relative paths. The solution is to pass the filename in `sassOptions`. It's fine to pass the javascript file path: we are already providing the `data` option with the content to parse, so sass won't actually try to read the file. It is only used for resolving explicit relative imports.
1 parent 95f4d51 commit 9f58df2

File tree

2 files changed

+3
-4
lines changed

2 files changed

+3
-4
lines changed

index.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,11 @@ module.exports = (css, settings) => {
1414
const optionData = settings.sassOptions && settings.sassOptions.data || "";
1515
const data = optionData + "\n" + cssWithPlaceholders;
1616

17+
const file = settings.babel && settings.babel.filename;
18+
1719
const preprocessed = sass.renderSync(
1820
Object.assign(
19-
{},
21+
{file},
2022
settings.sassOptions,
2123
{ data }
2224
)).css.toString()

test.js

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -122,9 +122,6 @@ describe('styled-jsx-plugin-sass', () => {
122122

123123
assert.equal(
124124
plugin(file.toString(), {
125-
sassOptions: {
126-
includePaths: [path.join(__dirname, 'fixtures')]
127-
},
128125
babel: { filename }
129126
}).trim(),
130127
cleanup(`

0 commit comments

Comments
 (0)