Skip to content

Commit e595b70

Browse files
authored
feat: add support for Sass index files (#112)
1 parent f965d7c commit e595b70

File tree

4 files changed

+25
-0
lines changed

4 files changed

+25
-0
lines changed

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,7 @@
100100
"lint-staged": "^10.1.7",
101101
"postcss-import-sync2": "^1.1.0",
102102
"prettier": "^2.0.5",
103+
"sass-svg": "1.2.0",
103104
"ts-jest": "^25.4.0",
104105
"typescript": "^3.8.3"
105106
},

src/importers/__tests__/sassTildeImporter.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,12 @@ describe('importers / sassTildeImporter', () => {
3838
).toMatchObject({ file: 'node_modules/bootstrap/scss/_grid.scss' });
3939
});
4040

41+
it('should resolve index files', () => {
42+
expect(sassTildeImporter('~sass-svg', source, done)).toMatchObject({
43+
file: 'node_modules/sass-svg/_index.scss',
44+
});
45+
});
46+
4147
it('should resolve .css files', () => {
4248
expect(
4349
sassTildeImporter('~bootstrap/dist/css/bootstrap-grid.css', source, done),

src/importers/sassTildeImporter.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,12 @@ export const sassTildeImporter: sass.Importer = (
3434
);
3535
}
3636

37+
// Support index files.
38+
subpathsWithExts.push(
39+
`${nodeModSubpath}/_index.scss`,
40+
`${nodeModSubpath}/_index.sass`,
41+
);
42+
3743
// Support sass partials by including paths where the file is prefixed by an underscore.
3844
const basename = path.basename(nodeModSubpath);
3945
if (!basename.startsWith('_')) {

yarn.lock

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4240,13 +4240,25 @@ sane@^4.0.3:
42404240
minimist "^1.1.1"
42414241
walker "~1.0.5"
42424242

4243+
4244+
version "1.2.0"
4245+
resolved "https://registry.yarnpkg.com/sass-svg/-/sass-svg-1.2.0.tgz#dc7b954d073fe2416d9e069973b2ba4c658534b9"
4246+
integrity sha512-xEEyBGdzAGTAw3Njy8mNHoRmoD/VpXd75ENmSUh5EfvnvTUCxYta0i/PshBKZFudhfbTvfQAUiihfD+yLE0Arw==
4247+
dependencies:
4248+
sassdash "^0.9.0"
4249+
42434250
sass@^1.26.5:
42444251
version "1.26.5"
42454252
resolved "https://registry.yarnpkg.com/sass/-/sass-1.26.5.tgz#2d7aecfbbabfa298567c8f06615b6e24d2d68099"
42464253
integrity sha512-FG2swzaZUiX53YzZSjSakzvGtlds0lcbF+URuU9mxOv7WBh7NhXEVDa4kPKN4hN6fC2TkOTOKqiqp6d53N9X5Q==
42474254
dependencies:
42484255
chokidar ">=2.0.0 <4.0.0"
42494256

4257+
sassdash@^0.9.0:
4258+
version "0.9.0"
4259+
resolved "https://registry.yarnpkg.com/sassdash/-/sassdash-0.9.0.tgz#e2114e80af0c01639d1c6b88a3eb350740cb1169"
4260+
integrity sha512-1SIJltpUOCMY06uTEWrtXDtfGr39P2huhikbiAMU0v9S4PfL5StxGiz5Oo0HqyVpWZK3mAItYEntDikUSUyXeQ==
4261+
42504262
sax@~1.2.4:
42514263
version "1.2.4"
42524264
resolved "https://registry.yarnpkg.com/sax/-/sax-1.2.4.tgz#2816234e2378bddc4e5354fab5caa895df7100d9"

0 commit comments

Comments
 (0)