Skip to content

Commit

Permalink
fix: prefer sass/scss/css extensions (#711)
Browse files Browse the repository at this point in the history
  • Loading branch information
evilebottnawi authored Aug 8, 2019
1 parent 28f1884 commit 6fc9d4e
Showing 1 changed file with 19 additions and 2 deletions.
21 changes: 19 additions & 2 deletions lib/loader.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,23 @@ const normalizeOptions = require('./normalizeOptions');

let nodeSassJobQueue = null;

// Very hacky check
function hasGetResolve(loaderContext) {
return (
loaderContext.getResolve &&
// eslint-disable-next-line no-underscore-dangle
loaderContext._compiler &&
// eslint-disable-next-line no-underscore-dangle
loaderContext._compiler.resolverFactory &&
// eslint-disable-next-line no-underscore-dangle
loaderContext._compiler.resolverFactory._create &&
/cachedCleverMerge/.test(
// eslint-disable-next-line no-underscore-dangle
loaderContext._compiler.resolverFactory._create.toString()
)
);
}

/**
* The sass-loader makes node-sass and dart-sass available to webpack modules.
*
Expand All @@ -37,8 +54,8 @@ function sassLoader(content) {

let resolve = pify(this.resolve);

// Supported since v4.27.0
if (this.getResolve) {
// Supported since v4.36.0
if (hasGetResolve(self)) {
resolve = this.getResolve({
mainFields: ['sass', 'style', '...'],
extensions: ['.scss', '.sass', '.css', '...'],
Expand Down

0 comments on commit 6fc9d4e

Please sign in to comment.