Skip to content

Commit f524223

Browse files
fix: prefer scss, sass and css extensions in resolving (#645)
1 parent 2adcca3 commit f524223

File tree

11 files changed

+40
-29
lines changed

11 files changed

+40
-29
lines changed

.nycrc

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,6 @@
99
"lines": 97,
1010
"statements": 97,
1111
"functions": 100,
12-
"branches": 90,
12+
"branches": 89,
1313
"check-coverage": true
1414
}

.travis.yml

+8-15
Original file line numberDiff line numberDiff line change
@@ -8,28 +8,21 @@ jobs:
88
fast_finish: true
99
allow_failures:
1010
- env: WEBPACK_VERSION=canary
11-
- node_js: 9
1211
include:
13-
- &test-latest
14-
stage: Webpack latest
15-
node_js: 6
16-
env: WEBPACK_VERSION=latest JOB_PART=test
17-
script: npm run travis:$JOB_PART
18-
- <<: *test-latest
19-
node_js: 8
12+
- node_js: 6
2013
env: WEBPACK_VERSION=latest JOB_PART=lint
2114
script: npm run travis:$JOB_PART
22-
- <<: *test-latest
23-
node_js: 8
15+
- node_js: 6
16+
env: WEBPACK_VERSION=latest JOB_PART=test
17+
script: npm run travis:$JOB_PART
18+
- node_js: 8
2419
env: WEBPACK_VERSION=latest JOB_PART=coverage
2520
script: npm run travis:$JOB_PART
2621
after_success: 'bash <(curl -s https://codecov.io/bash)'
27-
- stage: Webpack canary
28-
node_js: 8
29-
env: WEBPACK_VERSION=4.0.0 JOB_PART=test
22+
- node_js: 10
23+
env: WEBPACK_VERSION=latest JOB_PART=test
3024
script: npm run travis:$JOB_PART
31-
- stage: NodeJS Next
32-
node_js: 9
25+
- node_js: 11
3326
env: WEBPACK_VERSION=latest JOB_PART=test
3427
script: npm run travis:$JOB_PART
3528
before_install:

lib/loader.js

+10-5
Original file line numberDiff line numberDiff line change
@@ -35,14 +35,19 @@ function sassLoader(content) {
3535
);
3636
}
3737

38+
let resolve = pify(this.resolve);
39+
40+
// Supported since v4.27.0
41+
if (this.getResolve) {
42+
resolve = this.getResolve({
43+
extensions: ['.scss', '.sass', '.css'],
44+
});
45+
}
46+
3847
const options = normalizeOptions(
3948
this,
4049
content,
41-
webpackImporter(
42-
resourcePath,
43-
pify(this.resolve.bind(this)),
44-
addNormalizedDependency
45-
)
50+
webpackImporter(resourcePath, resolve, addNormalizedDependency)
4651
);
4752

4853
// Skip empty files, otherwise it will stop webpack, see issue #21

package-lock.json

+7-7
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

test/index.test.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -295,7 +295,7 @@ implementations.forEach((implementation) => {
295295
// This number needs to be updated if imports.scss or any dependency of that changes.
296296
// Node Sass includes a duplicate entry, Dart Sass does not.
297297
sourceMap.sources.should.have.length(
298-
implementation === nodeSass ? 11 : 10
298+
implementation === nodeSass ? 12 : 11
299299
);
300300
sourceMap.sources.forEach((sourcePath) =>
301301
fs.existsSync(path.resolve(sourceMap.sourceRoot, sourcePath))

test/node_modules/@org/style.js

+1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

test/node_modules/@org/style.scss

+3
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

test/node_modules/scss/style.js

+1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

test/node_modules/scss/style.scss

+3
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

test/sass/imports.sass

+2
Original file line numberDiff line numberDiff line change
@@ -24,3 +24,5 @@
2424
@import ~module
2525
/* @import ~another */
2626
@import ~another
27+
// Should prefer `scss`
28+
@import "~@org/style"

test/scss/imports.scss

+3
Original file line numberDiff line numberDiff line change
@@ -24,3 +24,6 @@
2424
@import "~module";
2525
/* @import "~another"; */
2626
@import "~another";
27+
/* @import "~@org/style"; */
28+
// Should prefer `scss`
29+
@import "~@org/style";

0 commit comments

Comments
 (0)