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

style-resources-loader

Package Overview
Dependencies
Maintainers
1
Versions
22
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

style-resources-loader

CSS processor resources loader for webpack

  • 1.5.0
  • latest
  • Source
  • npm
  • Socket score

Version published
Maintainers
1
Created

What is style-resources-loader?

The style-resources-loader npm package is a webpack loader that injects shared style resources (such as variables, mixins, and functions) into every style file processed by webpack. This is particularly useful for projects using CSS preprocessors like Sass, Less, or Stylus, as it allows you to avoid repetitive imports and ensures that all style files have access to the same set of resources.

What are style-resources-loader's main functionalities?

Injecting Shared Resources

This feature allows you to inject shared style resources into every SCSS file processed by webpack. The example demonstrates how to configure webpack to use style-resources-loader to inject variables and mixins from specified SCSS files.

{
  module: {
    rules: [
      {
        test: /\.scss$/,
        use: [
          'style-loader',
          'css-loader',
          'sass-loader',
          {
            loader: 'style-resources-loader',
            options: {
              patterns: [
                path.resolve(__dirname, 'src/styles/variables.scss'),
                path.resolve(__dirname, 'src/styles/mixins.scss')
              ]
            }
          }
        ]
      }
    ]
  }
}

Support for Multiple Preprocessors

This feature demonstrates the flexibility of style-resources-loader in supporting multiple CSS preprocessors. The example shows how to configure webpack to inject shared resources for SCSS, Less, and Stylus files.

{
  module: {
    rules: [
      {
        test: /\.(scss|sass|less|styl)$/,
        use: [
          'style-loader',
          'css-loader',
          {
            loader: 'style-resources-loader',
            options: {
              patterns: [
                path.resolve(__dirname, 'src/styles/resources.scss'),
                path.resolve(__dirname, 'src/styles/resources.less'),
                path.resolve(__dirname, 'src/styles/resources.styl')
              ]
            }
          }
        ]
      }
    ]
  }
}

Other packages similar to style-resources-loader

Keywords

FAQs

Package last updated on 08 Dec 2021

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