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.5.3 to 1.5.4

0

lib/importer.d.ts

@@ -0,0 +0,0 @@ import { SassPluginOptions } from "./index";

@@ -0,0 +0,0 @@ "use strict";

@@ -0,0 +0,0 @@ import { OnLoadResult } from "esbuild";

@@ -0,0 +0,0 @@ "use strict";

import { Plugin } from "esbuild";
import { SassPluginOptions } from "./index";
export declare function sassPlugin(options?: SassPluginOptions): Plugin;

@@ -0,0 +0,0 @@ "use strict";

@@ -0,0 +0,0 @@ import { SassPluginOptions, Type } from "./index";

@@ -0,0 +0,0 @@ "use strict";

2

package.json
{
"name": "esbuild-sass-plugin",
"version": "1.5.3",
"version": "1.5.4",
"description": "esbuild plugin for sass/scss files supporting both css loader and css result import (lit-element)",

@@ -5,0 +5,0 @@ "main": "lib/index.js",

@@ -88,2 +88,3 @@ ![logo created with https://cooltext.com](https://images.cooltext.com/5500652.png)

|exclude|regex|undefined|
|importMapper|function|undefined|

@@ -127,2 +128,30 @@

### ImportMapper Option
Function to customize re-map import path, both `import` in ts code and `@import`
in scss coverd.
You can use this option to re-map import paths like tsconfig's `paths` option.
e.g.
```json
//tsconfig
{
"compilerOptions": {
"baseUrl": ".",
"paths": {
"@img/*": ["./assets/images/*"] //map image files
}
}
}
```
Now you can resolve these paths with `importMapper`
```javascript
await esbuild.build({
...
plugins: [sassPlugin({
importMapper: (path)=>
path.replace(/^@img\//,"./assets/images/")
})]
})
```
### Transform Option

@@ -129,0 +158,0 @@ ```typescript

import {SassPluginOptions} from "./index";
import resolve from "resolve";
export function createSassImporter({basedir = process.cwd()}: SassPluginOptions) {
export function createSassImporter({basedir = process.cwd(), importMapper }: SassPluginOptions) {

@@ -12,2 +12,5 @@ const opts = {basedir, extensions: [".scss", ".sass", ".css"]};

}
if (importMapper) {
url = importMapper(url)
}
try {

@@ -14,0 +17,0 @@ return {file: resolve.sync(url, opts)};

@@ -7,2 +7,7 @@ import {OnLoadResult} from "esbuild";

export type SassPluginOptions = {
/**
* Function to transform import path. Not just paths by @import
* directive, but also paths imported by ts code.
*/
importMapper?:(url: string) => string

@@ -9,0 +14,0 @@ /**

@@ -67,2 +67,8 @@ import {OnLoadArgs, OnLoadResult, OnResolveArgs, Plugin} from "esbuild";

}
const mapper = options.importMapper
if(mapper) {
path = mapper(path)
}
const paths = options.includePaths ? [resolveDir, ...options.includePaths] : [resolveDir];

@@ -69,0 +75,0 @@ return require.resolve(path, {paths});

@@ -0,0 +0,0 @@ import {SassPluginOptions, Type} from "./index";

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