esbuild-sass-plugin
Advanced tools
Comparing version 1.4.3 to 1.4.4
@@ -5,2 +5,3 @@ import { OnLoadResult } from "esbuild"; | ||
export declare type SassPluginOptions = { | ||
exclude?: RegExp; | ||
implementation?: string; | ||
@@ -7,0 +8,0 @@ basedir?: string; |
@@ -111,8 +111,17 @@ "use strict"; | ||
} | ||
function useExclude(callback) { | ||
const exclude = options.exclude; | ||
if (exclude) { | ||
return (args) => exclude.test(args.path) ? null : callback(args); | ||
} | ||
else { | ||
return callback; | ||
} | ||
} | ||
return { | ||
name: "sass-plugin", | ||
setup: function (build) { | ||
build.onResolve({ filter: /\.(s[ac]ss|css)$/ }, (args) => { | ||
build.onResolve({ filter: /\.(s[ac]ss|css)$/ }, useExclude((args) => { | ||
return { path: args.path, namespace: "sass", pluginData: args }; | ||
}); | ||
})); | ||
let cached; | ||
@@ -119,0 +128,0 @@ if (cache) { |
{ | ||
"name": "esbuild-sass-plugin", | ||
"version": "1.4.3", | ||
"version": "1.4.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) | ||
|transform|function|undefined| | ||
|exclude|regex|undefined| | ||
@@ -114,2 +115,15 @@ | ||
### Exclude Option | ||
Used to exclude paths from the plugin | ||
e.g. | ||
```javascript | ||
await esbuild.build({ | ||
... | ||
plugins: [sassPlugin({ | ||
exclude: /^http:\/\//, // ignores urls | ||
})] | ||
}) | ||
``` | ||
### Transform Option | ||
@@ -116,0 +130,0 @@ ```typescript |
@@ -9,2 +9,7 @@ import {OnLoadResult} from "esbuild"; | ||
/** | ||
* | ||
*/ | ||
exclude?: RegExp; | ||
/** | ||
* "sass" for dart-sass (compiled to javascript, slow) or "node-sass" (libsass, fast yet deprecated) | ||
@@ -11,0 +16,0 @@ * You can pass the module name of any other implementation as long as it is API compatible |
@@ -130,2 +130,11 @@ import {Loader, OnLoadArgs, OnLoadResult, OnResolveArgs, Plugin} from "esbuild"; | ||
function useExclude(callback) { | ||
const exclude = options.exclude; | ||
if (exclude) { | ||
return (args: OnResolveArgs) => exclude.test(args.path) ? null : callback(args) | ||
} else { | ||
return callback | ||
} | ||
} | ||
return { | ||
@@ -135,5 +144,5 @@ name: "sass-plugin", | ||
build.onResolve({filter: /\.(s[ac]ss|css)$/}, (args) => { | ||
build.onResolve({filter: /\.(s[ac]ss|css)$/}, useExclude((args) => { | ||
return {path: args.path, namespace: "sass", pluginData: args}; | ||
}); | ||
})); | ||
@@ -140,0 +149,0 @@ let cached: ( |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
49241
717
264