diff --git a/src/SassError.js b/src/SassError.js index 4b8a9750..d602aa9e 100644 --- a/src/SassError.js +++ b/src/SassError.js @@ -4,6 +4,11 @@ class SassError extends Error { this.name = "SassError"; + // Instruct webpack to hide the JS stack from the console. + // Usually you're only interested in the SASS error in this case. + this.hideStack = true; + Error.captureStackTrace(this, this.constructor); + if ( typeof sassError.line !== "undefined" || typeof sassError.column !== "undefined" @@ -24,12 +29,6 @@ class SassError extends Error { /^Error: /, "" )}`; - - // Instruct webpack to hide the JS stack from the console. - // Usually you're only interested in the SASS stack in this case. - this.hideStack = true; - - Error.captureStackTrace(this, this.constructor); } } } diff --git a/test/__snapshots__/loader.test.js.snap b/test/__snapshots__/loader.test.js.snap index 195e08df..308c3699 100644 --- a/test/__snapshots__/loader.test.js.snap +++ b/test/__snapshots__/loader.test.js.snap @@ -476,7 +476,7 @@ exports[`loader should not use .import.sass files ('dart-sass', 'legacy' API, 's exports[`loader should not use .import.sass files ('dart-sass', 'modern' API, 'sass' syntax): errors 1`] = ` Array [ "ModuleBuildError: Module build failed (from ../src/cjs.js): -SassError: SassError: Can't find stylesheet to import.", +SassError: Can't find stylesheet to import.", ] `; @@ -494,7 +494,7 @@ exports[`loader should not use .import.sass files ('sass-embedded', 'legacy' API exports[`loader should not use .import.sass files ('sass-embedded', 'modern' API, 'sass' syntax): errors 1`] = ` Array [ "ModuleBuildError: Module build failed (from ../src/cjs.js): -SassError: SassError: Error: Can't find stylesheet to import.", +SassError: Error: Can't find stylesheet to import.", ] `; @@ -512,7 +512,7 @@ exports[`loader should not use .import.scss files ('dart-sass', 'legacy' API, 's exports[`loader should not use .import.scss files ('dart-sass', 'modern' API, 'scss' syntax): errors 1`] = ` Array [ "ModuleBuildError: Module build failed (from ../src/cjs.js): -SassError: SassError: Can't find stylesheet to import.", +SassError: Can't find stylesheet to import.", ] `; @@ -530,7 +530,7 @@ exports[`loader should not use .import.scss files ('sass-embedded', 'legacy' API exports[`loader should not use .import.scss files ('sass-embedded', 'modern' API, 'scss' syntax): errors 1`] = ` Array [ "ModuleBuildError: Module build failed (from ../src/cjs.js): -SassError: SassError: Error: Can't find stylesheet to import.", +SassError: Error: Can't find stylesheet to import.", ] `; @@ -557,7 +557,7 @@ exports[`loader should output an understandable error ('dart-sass', 'legacy' API exports[`loader should output an understandable error ('dart-sass', 'modern' API, 'sass' syntax): errors 1`] = ` Array [ "ModuleBuildError: Module build failed (from ../src/cjs.js): -SassError: SassError: Expected newline.", +SassError: Expected newline.", ] `; @@ -566,7 +566,7 @@ exports[`loader should output an understandable error ('dart-sass', 'modern' API exports[`loader should output an understandable error ('dart-sass', 'modern' API, 'scss' syntax): errors 1`] = ` Array [ "ModuleBuildError: Module build failed (from ../src/cjs.js): -SassError: SassError: expected \\"{\\".", +SassError: expected \\"{\\".", ] `; @@ -611,7 +611,7 @@ exports[`loader should output an understandable error ('sass-embedded', 'legacy' exports[`loader should output an understandable error ('sass-embedded', 'modern' API, 'sass' syntax): errors 1`] = ` Array [ "ModuleBuildError: Module build failed (from ../src/cjs.js): -SassError: SassError: Error: Expected newline.", +SassError: Error: Expected newline.", ] `; @@ -620,7 +620,7 @@ exports[`loader should output an understandable error ('sass-embedded', 'modern' exports[`loader should output an understandable error ('sass-embedded', 'modern' API, 'scss' syntax): errors 1`] = ` Array [ "ModuleBuildError: Module build failed (from ../src/cjs.js): -SassError: SassError: Error: expected \\"{\\".", +SassError: Error: expected \\"{\\".", ] `; @@ -647,7 +647,7 @@ exports[`loader should output an understandable error when a file could not be f exports[`loader should output an understandable error when a file could not be found ('dart-sass', 'modern' API, 'sass' syntax): errors 1`] = ` Array [ "ModuleBuildError: Module build failed (from ../src/cjs.js): -SassError: SassError: Can't find stylesheet to import.", +SassError: Can't find stylesheet to import.", ] `; @@ -656,7 +656,7 @@ exports[`loader should output an understandable error when a file could not be f exports[`loader should output an understandable error when a file could not be found ('dart-sass', 'modern' API, 'scss' syntax): errors 1`] = ` Array [ "ModuleBuildError: Module build failed (from ../src/cjs.js): -SassError: SassError: Can't find stylesheet to import.", +SassError: Can't find stylesheet to import.", ] `; @@ -701,7 +701,7 @@ exports[`loader should output an understandable error when a file could not be f exports[`loader should output an understandable error when a file could not be found ('sass-embedded', 'modern' API, 'sass' syntax): errors 1`] = ` Array [ "ModuleBuildError: Module build failed (from ../src/cjs.js): -SassError: SassError: Error: Can't find stylesheet to import.", +SassError: Error: Can't find stylesheet to import.", ] `; @@ -710,7 +710,7 @@ exports[`loader should output an understandable error when a file could not be f exports[`loader should output an understandable error when a file could not be found ('sass-embedded', 'modern' API, 'scss' syntax): errors 1`] = ` Array [ "ModuleBuildError: Module build failed (from ../src/cjs.js): -SassError: SassError: Error: Can't find stylesheet to import.", +SassError: Error: Can't find stylesheet to import.", ] `; @@ -737,7 +737,7 @@ exports[`loader should output an understandable error when a file could not be f exports[`loader should output an understandable error when a file could not be found using "@use" rule ('dart-sass', 'modern' API, 'sass' syntax): errors 1`] = ` Array [ "ModuleBuildError: Module build failed (from ../src/cjs.js): -SassError: SassError: Can't find stylesheet to import.", +SassError: Can't find stylesheet to import.", ] `; @@ -746,7 +746,7 @@ exports[`loader should output an understandable error when a file could not be f exports[`loader should output an understandable error when a file could not be found using "@use" rule ('dart-sass', 'modern' API, 'scss' syntax): errors 1`] = ` Array [ "ModuleBuildError: Module build failed (from ../src/cjs.js): -SassError: SassError: Can't find stylesheet to import.", +SassError: Can't find stylesheet to import.", ] `; @@ -773,7 +773,7 @@ exports[`loader should output an understandable error when a file could not be f exports[`loader should output an understandable error when a file could not be found using "@use" rule ('sass-embedded', 'modern' API, 'sass' syntax): errors 1`] = ` Array [ "ModuleBuildError: Module build failed (from ../src/cjs.js): -SassError: SassError: Error: Can't find stylesheet to import.", +SassError: Error: Can't find stylesheet to import.", ] `; @@ -782,7 +782,7 @@ exports[`loader should output an understandable error when a file could not be f exports[`loader should output an understandable error when a file could not be found using "@use" rule ('sass-embedded', 'modern' API, 'scss' syntax): errors 1`] = ` Array [ "ModuleBuildError: Module build failed (from ../src/cjs.js): -SassError: SassError: Error: Can't find stylesheet to import.", +SassError: Error: Can't find stylesheet to import.", ] `; @@ -809,7 +809,7 @@ exports[`loader should output an understandable error when the problem in "@impo exports[`loader should output an understandable error when the problem in "@import" ('dart-sass', 'modern' API, 'sass' syntax): errors 1`] = ` Array [ "ModuleBuildError: Module build failed (from ../src/cjs.js): -SassError: SassError: Expected newline.", +SassError: Expected newline.", ] `; @@ -818,7 +818,7 @@ exports[`loader should output an understandable error when the problem in "@impo exports[`loader should output an understandable error when the problem in "@import" ('dart-sass', 'modern' API, 'scss' syntax): errors 1`] = ` Array [ "ModuleBuildError: Module build failed (from ../src/cjs.js): -SassError: SassError: expected \\"{\\".", +SassError: expected \\"{\\".", ] `; @@ -863,7 +863,7 @@ exports[`loader should output an understandable error when the problem in "@impo exports[`loader should output an understandable error when the problem in "@import" ('sass-embedded', 'modern' API, 'sass' syntax): errors 1`] = ` Array [ "ModuleBuildError: Module build failed (from ../src/cjs.js): -SassError: SassError: Error: Expected newline.", +SassError: Error: Expected newline.", ] `; @@ -872,7 +872,7 @@ exports[`loader should output an understandable error when the problem in "@impo exports[`loader should output an understandable error when the problem in "@import" ('sass-embedded', 'modern' API, 'scss' syntax): errors 1`] = ` Array [ "ModuleBuildError: Module build failed (from ../src/cjs.js): -SassError: SassError: Error: expected \\"{\\".", +SassError: Error: expected \\"{\\".", ] `; @@ -899,7 +899,7 @@ exports[`loader should output an understandable error with a problem in "@use" ( exports[`loader should output an understandable error with a problem in "@use" ('dart-sass', 'modern' API, 'sass' syntax): errors 1`] = ` Array [ "ModuleBuildError: Module build failed (from ../src/cjs.js): -SassError: SassError: Expected newline.", +SassError: Expected newline.", ] `; @@ -908,7 +908,7 @@ exports[`loader should output an understandable error with a problem in "@use" ( exports[`loader should output an understandable error with a problem in "@use" ('dart-sass', 'modern' API, 'scss' syntax): errors 1`] = ` Array [ "ModuleBuildError: Module build failed (from ../src/cjs.js): -SassError: SassError: expected \\"{\\".", +SassError: expected \\"{\\".", ] `; @@ -935,7 +935,7 @@ exports[`loader should output an understandable error with a problem in "@use" ( exports[`loader should output an understandable error with a problem in "@use" ('sass-embedded', 'modern' API, 'sass' syntax): errors 1`] = ` Array [ "ModuleBuildError: Module build failed (from ../src/cjs.js): -SassError: SassError: Error: Expected newline.", +SassError: Error: Expected newline.", ] `; @@ -944,7 +944,7 @@ exports[`loader should output an understandable error with a problem in "@use" ( exports[`loader should output an understandable error with a problem in "@use" ('sass-embedded', 'modern' API, 'scss' syntax): errors 1`] = ` Array [ "ModuleBuildError: Module build failed (from ../src/cjs.js): -SassError: SassError: Error: expected \\"{\\".", +SassError: Error: expected \\"{\\".", ] `; @@ -2409,7 +2409,7 @@ exports[`loader should throw an error on ambiguous import (only on "dart-sass") exports[`loader should throw an error on ambiguous import (only on "dart-sass") ('dart-sass', 'modern' API, 'sass' syntax): errors 1`] = ` Array [ "ModuleBuildError: Module build failed (from ../src/cjs.js): -SassError: SassError: It's not clear which file to import. Found:", +SassError: It's not clear which file to import. Found:", ] `; @@ -2418,7 +2418,7 @@ exports[`loader should throw an error on ambiguous import (only on "dart-sass") exports[`loader should throw an error on ambiguous import (only on "dart-sass") ('dart-sass', 'modern' API, 'scss' syntax): errors 1`] = ` Array [ "ModuleBuildError: Module build failed (from ../src/cjs.js): -SassError: SassError: It's not clear which file to import. Found:", +SassError: It's not clear which file to import. Found:", ] `; @@ -2453,7 +2453,7 @@ exports[`loader should throw an error on ambiguous import (only on "dart-sass") exports[`loader should throw an error on ambiguous import (only on "dart-sass") ('sass-embedded', 'modern' API, 'sass' syntax): errors 1`] = ` Array [ "ModuleBuildError: Module build failed (from ../src/cjs.js): -SassError: SassError: Error: It's not clear which file to import. Found:", +SassError: Error: It's not clear which file to import. Found:", ] `; @@ -2462,7 +2462,7 @@ exports[`loader should throw an error on ambiguous import (only on "dart-sass") exports[`loader should throw an error on ambiguous import (only on "dart-sass") ('sass-embedded', 'modern' API, 'scss' syntax): errors 1`] = ` Array [ "ModuleBuildError: Module build failed (from ../src/cjs.js): -SassError: SassError: Error: It's not clear which file to import. Found:", +SassError: Error: It's not clear which file to import. Found:", ] `; @@ -2489,7 +2489,7 @@ exports[`loader should throw an error on circular import ('dart-sass', 'legacy' exports[`loader should throw an error on circular import ('dart-sass', 'modern' API, 'sass' syntax): errors 1`] = ` Array [ "ModuleBuildError: Module build failed (from ../src/cjs.js): -SassError: SassError: This file is already being loaded.", +SassError: This file is already being loaded.", ] `; @@ -2498,7 +2498,7 @@ exports[`loader should throw an error on circular import ('dart-sass', 'modern' exports[`loader should throw an error on circular import ('dart-sass', 'modern' API, 'scss' syntax): errors 1`] = ` Array [ "ModuleBuildError: Module build failed (from ../src/cjs.js): -SassError: SassError: This file is already being loaded.", +SassError: This file is already being loaded.", ] `; @@ -2543,7 +2543,7 @@ exports[`loader should throw an error on circular import ('sass-embedded', 'lega exports[`loader should throw an error on circular import ('sass-embedded', 'modern' API, 'sass' syntax): errors 1`] = ` Array [ "ModuleBuildError: Module build failed (from ../src/cjs.js): -SassError: SassError: Error: This file is already being loaded.", +SassError: Error: This file is already being loaded.", ] `; @@ -2552,7 +2552,7 @@ exports[`loader should throw an error on circular import ('sass-embedded', 'mode exports[`loader should throw an error on circular import ('sass-embedded', 'modern' API, 'scss' syntax): errors 1`] = ` Array [ "ModuleBuildError: Module build failed (from ../src/cjs.js): -SassError: SassError: Error: This file is already being loaded.", +SassError: Error: This file is already being loaded.", ] `; @@ -2579,7 +2579,7 @@ exports[`loader should throw an error on circular use ('dart-sass', 'legacy' API exports[`loader should throw an error on circular use ('dart-sass', 'modern' API, 'sass' syntax): errors 1`] = ` Array [ "ModuleBuildError: Module build failed (from ../src/cjs.js): -SassError: SassError: Module loop: this module is already being loaded.", +SassError: Module loop: this module is already being loaded.", ] `; @@ -2588,7 +2588,7 @@ exports[`loader should throw an error on circular use ('dart-sass', 'modern' API exports[`loader should throw an error on circular use ('dart-sass', 'modern' API, 'scss' syntax): errors 1`] = ` Array [ "ModuleBuildError: Module build failed (from ../src/cjs.js): -SassError: SassError: This file is already being loaded.", +SassError: This file is already being loaded.", ] `; @@ -2615,7 +2615,7 @@ exports[`loader should throw an error on circular use ('sass-embedded', 'legacy' exports[`loader should throw an error on circular use ('sass-embedded', 'modern' API, 'sass' syntax): errors 1`] = ` Array [ "ModuleBuildError: Module build failed (from ../src/cjs.js): -SassError: SassError: Error: Module loop: this module is already being loaded.", +SassError: Error: Module loop: this module is already being loaded.", ] `; @@ -2624,7 +2624,7 @@ exports[`loader should throw an error on circular use ('sass-embedded', 'modern' exports[`loader should throw an error on circular use ('sass-embedded', 'modern' API, 'scss' syntax): errors 1`] = ` Array [ "ModuleBuildError: Module build failed (from ../src/cjs.js): -SassError: SassError: Error: This file is already being loaded.", +SassError: Error: This file is already being loaded.", ] `; @@ -2651,7 +2651,7 @@ exports[`loader should throw an error with a explicit file and a file does not e exports[`loader should throw an error with a explicit file and a file does not exist ('dart-sass', 'modern' API, 'sass' syntax): errors 1`] = ` Array [ "ModuleBuildError: Module build failed (from ../src/cjs.js): -SassError: SassError: Can't find stylesheet to import.", +SassError: Can't find stylesheet to import.", ] `; @@ -2660,7 +2660,7 @@ exports[`loader should throw an error with a explicit file and a file does not e exports[`loader should throw an error with a explicit file and a file does not exist ('dart-sass', 'modern' API, 'scss' syntax): errors 1`] = ` Array [ "ModuleBuildError: Module build failed (from ../src/cjs.js): -SassError: SassError: Can't find stylesheet to import.", +SassError: Can't find stylesheet to import.", ] `; @@ -2705,7 +2705,7 @@ exports[`loader should throw an error with a explicit file and a file does not e exports[`loader should throw an error with a explicit file and a file does not exist ('sass-embedded', 'modern' API, 'sass' syntax): errors 1`] = ` Array [ "ModuleBuildError: Module build failed (from ../src/cjs.js): -SassError: SassError: Error: Can't find stylesheet to import.", +SassError: Error: Can't find stylesheet to import.", ] `; @@ -2714,7 +2714,7 @@ exports[`loader should throw an error with a explicit file and a file does not e exports[`loader should throw an error with a explicit file and a file does not exist ('sass-embedded', 'modern' API, 'scss' syntax): errors 1`] = ` Array [ "ModuleBuildError: Module build failed (from ../src/cjs.js): -SassError: SassError: Error: Can't find stylesheet to import.", +SassError: Error: Can't find stylesheet to import.", ] `; @@ -2741,7 +2741,7 @@ exports[`loader should throw an error with a explicit file and a file does not e exports[`loader should throw an error with a explicit file and a file does not exist using "@use" rule ('dart-sass', 'modern' API, 'sass' syntax): errors 1`] = ` Array [ "ModuleBuildError: Module build failed (from ../src/cjs.js): -SassError: SassError: Can't find stylesheet to import.", +SassError: Can't find stylesheet to import.", ] `; @@ -2750,7 +2750,7 @@ exports[`loader should throw an error with a explicit file and a file does not e exports[`loader should throw an error with a explicit file and a file does not exist using "@use" rule ('dart-sass', 'modern' API, 'scss' syntax): errors 1`] = ` Array [ "ModuleBuildError: Module build failed (from ../src/cjs.js): -SassError: SassError: Can't find stylesheet to import.", +SassError: Can't find stylesheet to import.", ] `; @@ -2777,7 +2777,7 @@ exports[`loader should throw an error with a explicit file and a file does not e exports[`loader should throw an error with a explicit file and a file does not exist using "@use" rule ('sass-embedded', 'modern' API, 'sass' syntax): errors 1`] = ` Array [ "ModuleBuildError: Module build failed (from ../src/cjs.js): -SassError: SassError: Error: Can't find stylesheet to import.", +SassError: Error: Can't find stylesheet to import.", ] `; @@ -2786,7 +2786,7 @@ exports[`loader should throw an error with a explicit file and a file does not e exports[`loader should throw an error with a explicit file and a file does not exist using "@use" rule ('sass-embedded', 'modern' API, 'scss' syntax): errors 1`] = ` Array [ "ModuleBuildError: Module build failed (from ../src/cjs.js): -SassError: SassError: Error: Can't find stylesheet to import.", +SassError: Error: Can't find stylesheet to import.", ] `;