question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Since sass-loader 12.0.0 the `@debug` doesn't work with Sass >= 1.43.4

See original GitHub issue

Bug report

The @debug output in SCSS/SASS works only with:

  • Sass <= 1.52.3 + JS API
  • Sass <= 1.52.3 + sass-loader <= 11.1.1
  • Sass 1.43.3 + sass-loader 13.0.0 (lastest)

Used

  • node v16.13.1 (npm v8.1.2)
  • webpack: 5.73.0
  • sass: 1.43.3 - 1.52.3
  • sass-loader: 11.1.1 - 13.0.0

How Do We Reproduce?

Create 3 files in a directory:

package.json

{
    "scripts": {
      "build": "webpack"
    },
    "devDependencies": {
      "css-loader": "^6.7.1",
      "mini-css-extract-plugin": "^2.6.0",
      "sass": "^1.52.3",
      "sass-loader": "^12.0.0",
      "webpack": "^5.73.0",
      "webpack-cli": "^4.9.2"
    }
  }

style.scss

$color: red;
h1 {
    color: $color;
}
@debug '*** Color: #{$color}';

webpack.config.js

const path = require('path');
const MiniCssExtractPlugin = require('mini-css-extract-plugin');
module.exports = {
  mode: 'development',
  entry: {
    'style': path.resolve(__dirname, "style.scss"),
  },
  plugins: [new MiniCssExtractPlugin()],
  module: {
    rules: [
      {
        test: /\.(css|sass|scss)$/,
        use: [MiniCssExtractPlugin.loader, 'css-loader', 'sass-loader']
      },
    ],
  },
};

Install npm modules:

npm i

Show result in console output:

npm run build

Expected the output in console: Debug: *** Color: red Received - nothing.

How to view the @debug output

Change the version of sass-loader from ^12.0.0 (or ^13.0.0) to 11.1.1 in package.json and update npm module:

npm i

Show result in console output:

npm run build

Now you should see the output in console: Debug: *** Color: red.


Who broke compatibility: Sass since 1.43.4 or sass-loader since 12.0.0?

Issue Analytics

  • State:closed
  • Created a year ago
  • Comments:5 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
alexander-akaitcommented, Jun 14, 2022

@webdiscus I think wen can remove unnecessary lines

1reaction
webdiscuscommented, Jun 14, 2022

@alexander-akait

Thank you for Tip.

The webpack level option has no effect:

  infrastructureLogging: {
    level: 'log',
    debug: ['sass-loader'],
  },

💡 I found how to enable @debug output:

stats: {
  loggingDebug: ['sass-loader'],
}

It would be nice to have it in readme 😉

The output of Webpack is too “informative”:

DEBUG LOG from ./node_modules/sass-loader/dist/cjs.js sass-loader ./node_modules/css-loader/dist/cjs.js!./node_modules/sass-loader/dist/cjs.js!./style.scss
    file:///Users/user/Developer/Projects/github/sass-debug-bug/style.scss:4:0: 
    file:///Users/user/Developer/Projects/github/sass-debug-bug/style.scss:5:0: *** Color: red
    file:///Users/user/Developer/Projects/github/sass-debug-bug/style.scss:6:0: *** Color: green
    file:///Users/user/Developer/Projects/github/sass-debug-bug/style.scss:7:0: *** Color: blue

Expected pure Debug output w/o a path to file at each line, so is the output with sass-loader: 11.1.1:

style.scss:5 Debug: 
style.scss:6 Debug: *** Color: red
style.scss:7 Debug: *** Color: green
style.scss:8 Debug: *** Color: blue
Read more comments on GitHub >

github_iconTop Results From Across the Web

sass-loader - webpack - JS.ORG
This allows you to control the versions of all your dependencies, and to choose which Sass implementation to use. Note. We highly recommend...
Read more >
Module not found: Error: Can't resolve 'sass-loader'
Go to the project and run below two commands npm install sass-loader -D npm install node-sass -D.
Read more >
Breaking Change: Slash as Division - Sass
Because Sass is a CSS superset, we're matching CSS's syntax by redefining / to be only a separator. / will be treated as...
Read more >
Module not found: Can't resolve 'sass-loader' | bobbyhadz
Make sure to restart your development server and your IDE if necessary. Your dev server won't pick up the changes until you stop...
Read more >
sass-loader - Awesome JS
added support for sass-embedded (faster than node-sass ), feel free to feedback; added the api option ( modern api is experimental and currently...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found