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

esbuild-sass-plugin

Package Overview
Dependencies
Maintainers
1
Versions
90
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

esbuild-sass-plugin - npm Package Compare versions

Comparing version 1.4.4 to 1.4.5

31

lib/importer.js
"use strict";
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.createSassImporter = void 0;
const resolve_1 = __importDefault(require("resolve"));
const utils_1 = require("./utils");
const path_1 = require("path");
const fs_1 = require("fs");
const utils_1 = require("./utils");
function findModuleDirectory(basedir) {
const root = path_1.parse(basedir).root;
do {
const path = path_1.join(basedir, "node_modules");
if (fs_1.existsSync(path)) {
return path;
function createSassImporter({ basedir = process.cwd() }) {
const opts = { basedir, extensions: [".scss", ".sass", ".css"] };
return function importer(url, prev) {
if (url.startsWith("~")) {
const pathname = resolve_1.default.sync(url.slice(1), opts);
return { file: utils_1.moduleRelativeUrl(path_1.posix.dirname(prev), pathname) };
}
else {
basedir = path_1.dirname(basedir);
return { file: url };
}
} while (basedir !== root);
}
function createSassImporter({ basedir = process.cwd() }) {
const moduleDirectory = findModuleDirectory(basedir);
if (!moduleDirectory) {
console.log("unable to find 'node_modules' in: " + basedir);
}
return function importer(url, prev) {
const relativeBaseUrl = utils_1.moduleRelativeUrl(path_1.posix.dirname(prev), moduleDirectory);
return { file: url.replace(/^~/, relativeBaseUrl) };
};

@@ -28,0 +21,0 @@ }

@@ -17,5 +17,5 @@ "use strict";

let url = path_1.relative(basedir, pathname).replace(/\\/g, "/");
return /^\.\.?\//.test(url) ? `${url}/` : `./${url}/`;
return /^\.\.?\//.test(url) ? url : `./${url}`;
}
exports.moduleRelativeUrl = moduleRelativeUrl;
//# sourceMappingURL=utils.js.map
{
"name": "esbuild-sass-plugin",
"version": "1.4.4",
"version": "1.4.5",
"description": "esbuild plugin for sass/scss files supporting both css loader and css result import (lit-element)",

@@ -57,2 +57,3 @@ "main": "lib/index.js",

"picomatch": "^2.3.0",
"resolve": "^1.20.0",
"sass": "^1.34.0"

@@ -65,2 +66,3 @@ },

"@types/node": "^15.6.1",
"@types/resolve": "^1.20.0",
"@types/sass": "^1.16.0",

@@ -67,0 +69,0 @@ "chai": "^4.3.4",

import {SassPluginOptions} from "./index";
import {dirname, join, parse, posix} from "path";
import {existsSync} from "fs";
import resolve from "resolve";
import {moduleRelativeUrl} from "./utils";
import {posix} from "path";
function findModuleDirectory(basedir: string) {
const root = parse(basedir).root;
do {
const path = join(basedir, "node_modules");
if (existsSync(path)) {
return path;
} else {
basedir = dirname(basedir);
}
} while (basedir !== root);
}
export function createSassImporter({basedir = process.cwd()}: SassPluginOptions) {
const moduleDirectory = findModuleDirectory(basedir);
if (!moduleDirectory) {
console.log("unable to find 'node_modules' in: " + basedir);
}
const opts = {basedir, extensions: [".scss", ".sass", ".css"]};
return function importer(url, prev) {
const relativeBaseUrl = moduleRelativeUrl(posix.dirname(prev), moduleDirectory);
return {file: url.replace(/^~/, relativeBaseUrl!)};
if (url.startsWith("~")) {
const pathname = resolve.sync(url.slice(1), opts);
return {file: moduleRelativeUrl(posix.dirname(prev), pathname)};
} else {
return {file: url};
}
}
}

@@ -15,4 +15,4 @@ import {relative} from "path";

let url = relative(basedir, pathname).replace(/\\/g, "/");
return /^\.\.?\//.test(url) ? `${url}/` : `./${url}/`;
return /^\.\.?\//.test(url) ? url : `./${url}`;
}

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

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