Skip to content

Commit 1c59acd

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 2ace23f commit 1c59acd

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
@@ -20,9 +20,11 @@ module.exports = (css, settings) => {
2020
const optionData = settings.sassOptions && settings.sassOptions.data || "";
2121
const data = optionData + "\n" + cssWithPlaceholders;
2222

23+
const file = settings.babel && settings.babel.filename;
24+
2325
const preprocessed = sass.renderSync(
2426
Object.assign(
25-
{},
27+
{file},
2628
settings.sassOptions,
2729
{ data }
2830
)).css.toString()

test.js

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

133133
assert.equal(
134134
plugin(file.toString(), {
135-
sassOptions: {
136-
includePaths: [path.join(__dirname, 'fixtures')]
137-
},
138135
babel: { filename }
139136
}).trim(),
140137
cleanup(`

0 commit comments

Comments
 (0)