Skip to content

Cannot set property webpackLoaderContext of undefined #955

@wassim-k

Description

@wassim-k

Hi! 👋

Firstly, thanks for your work on this project! 🙂

I'm using a custom importer in my project and since the latest update I've been getting the following error:
SassError: Cannot set property 'webpackLoaderContext' of undefined

I've tested it on node v12.22.1 and 14.17.0

Here is the diff that solved my problem:

diff --git a/node_modules/sass-loader/dist/utils.js b/node_modules/sass-loader/dist/utils.js
index 6dac02c..24fc595 100644
--- a/node_modules/sass-loader/dist/utils.js
+++ b/node_modules/sass-loader/dist/utils.js
@@ -93,8 +93,8 @@ function isProductionLikeMode(loaderContext) {
 
 function proxyCustomImporters(importers, loaderContext) {
   return [].concat(importers).map(importer => function proxyImporter(...args) {
-    this.webpackLoaderContext = loaderContext;
-    return importer.apply(this, args);
+    const self = { webpackLoaderContext: loaderContext };
+    return importer.apply(self, args);
   });
 }
 

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions