Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

sass-loader

Package Overview
Dependencies
Maintainers
3
Versions
108
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

sass-loader

Sass loader for webpack

  • 16.0.3
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
13M
decreased by-8.5%
Maintainers
3
Weekly downloads
 
Created

What is sass-loader?

The sass-loader npm package is a loader for webpack that allows you to preprocess .scss or .sass files to standard CSS. It uses the Sass compiler to convert Sass code into CSS, and then webpack can bundle the resulting CSS into your final build.

What are sass-loader's main functionalities?

Compiling Sass/SCSS to CSS

This webpack configuration snippet demonstrates how to set up sass-loader in conjunction with css-loader and style-loader to process .scss files.

module.exports = {
  module: {
    rules: [
      {
        test: /\.scss$/,
        use: [
          'style-loader',
          'css-loader',
          'sass-loader'
        ]
      }
    ]
  }
};

Source Maps

This code enables source maps for easier debugging of Sass files. It configures sass-loader to generate source maps so that the browser dev tools can display the original Sass code instead of the compiled CSS.

module.exports = {
  module: {
    rules: [
      {
        test: /\.scss$/,
        use: [
          'style-loader',
          {
            loader: 'css-loader',
            options: { sourceMap: true }
          },
          {
            loader: 'sass-loader',
            options: { sourceMap: true }
          }
        ]
      }
    ]
  }
};

Custom Functions

This example shows how to add custom functions to the Sass compilation process. The custom 'pow' function can be used within Sass files to compute powers.

const sass = require('sass');

module.exports = {
  module: {
    rules: [
      {
        test: /\.scss$/,
        use: [
          'style-loader',
          'css-loader',
          {
            loader: 'sass-loader',
            options: {
              sassOptions: {
                functions: {
                  'pow($base, $exponent)': function(base, exponent) {
                    return new sass.types.Number(Math.pow(base.getValue(), exponent.getValue()));
                  }
                }
              }
            }
          }
        ]
      }
    ]
  }
};

Other packages similar to sass-loader

Keywords

FAQs

Package last updated on 01 Nov 2024

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc