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

sass-alias

Package Overview
Dependencies
Maintainers
1
Versions
8
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

sass-alias

sass-alias is a node-sass and dart-sass importer that brings aliasing to sass.

  • 2.0.1
  • latest
  • Source
  • npm
  • Socket score

Version published
Maintainers
1
Created
Source

sass-alias

sass-alias is a node-sass and dart-sass importer that brings aliasing to sass.

Installation

This package can be installed from npm or yarn by running one of the following commands.

Install using npm:

npm install sass-alias

Install using yarn:

yarn add sass-alias

Introduction

sass-alias brings sass the capability to import files using aliasing, this make importing more easy.

Example

Let's imagine we have the following project structure:

project
├───components
│	└───button
│		├───button.module.scss
│		└───button.component.js
│
└───resources
	└───scss
		├───colors.scss
		└───utils.scss

If we want to import colors into button.module.scss the resulting path should look like this

@import '../../resources/scss/colors.scss';

/* more scss stuff... */

If we use sass-alias the resulting path could look like this

@import '@scss/colors.scss';

/* more scss stuff... */

Configuration

using sass node-sass or dart-sass

import path from 'path';
import sass from 'sass';

import { create } from 'sass-alias';

sass.renderSync({
	importer: create({
		'@scss': path.join(__dirname, 'scss'),
	}),
});

using sass-loader in webpack

// webpack.config.js

const { create } = require('sass-alias');

module.exports = {
	module: {
		rules: [
			{
				test: /^.*\.(sass|scss)$/,
				use: [
					{
						loader: 'sass-loader',
						options: {
							sassOptions: {
								importer: create({
									'@scss': path.join(__dirname, 'scss'),
								}),
							},
						},
					},
				],
			},
		],
	},
};

License

This project is licensed under the MIT License, see the LICENSE.md file for details

Keywords

FAQs

Package last updated on 13 Feb 2023

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