Skip to content

Commit 21e00a7

Browse files
committed
feat: optimize debug message formatting, #1065
docs: add impofration how to enable @debug output
1 parent 2e1822e commit 21e00a7

File tree

2 files changed

+16
-1
lines changed

2 files changed

+16
-1
lines changed

README.md

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -756,6 +756,19 @@ module.exports = {
756756
};
757757
```
758758

759+
## How to enable `@debug` output
760+
761+
Defaults, the output of `@debug` messages is disabled.
762+
To enable it, add to **webpack.config.js** following:
763+
```js
764+
module.exports = {
765+
stats: {
766+
loggingDebug: ['sass-loader'],
767+
},
768+
//...
769+
}
770+
```
771+
759772
## Examples
760773

761774
### Extracts CSS into separate files

src/utils.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -157,13 +157,15 @@ async function getSassOptions(
157157
const logger = loaderContext.getLogger("sass-loader");
158158
const formatSpan = (span) =>
159159
`${span.url || "-"}:${span.start.line}:${span.start.column}: `;
160+
const formatDebugSpan = (span) =>
161+
`[debug:${span.start.line}:${span.start.column}] `;
160162

161163
options.logger = {
162164
debug(message, loggerOptions) {
163165
let builtMessage = "";
164166

165167
if (loggerOptions.span) {
166-
builtMessage = formatSpan(loggerOptions.span);
168+
builtMessage = formatDebugSpan(loggerOptions.span);
167169
}
168170

169171
builtMessage += message;

0 commit comments

Comments
 (0)