esbuild-sass-plugin
Advanced tools
Comparing version 3.1.0 to 3.2.0
import { OnLoadResult } from 'esbuild'; | ||
import { StringOptions } from 'sass'; | ||
import { sassPlugin } from './plugin'; | ||
export type Type = 'css' | 'style' | 'css-text' | 'lit-css' | ((cssText: string, nonce?: string) => string); | ||
export type Type = 'css' | 'local-css' | 'style' | 'css-text' | 'lit-css' | ((cssText: string, nonce?: string) => string); | ||
export type SassPluginOptions = StringOptions<'sync' | 'async'> & { | ||
@@ -6,0 +6,0 @@ filter?: RegExp; |
@@ -99,5 +99,5 @@ "use strict"; | ||
} | ||
return type === 'css' ? { | ||
return type === 'css' || type === 'local-css' ? { | ||
contents: cssText, | ||
loader: 'css', | ||
loader: type, | ||
resolveDir, | ||
@@ -104,0 +104,0 @@ warnings, |
@@ -116,2 +116,3 @@ "use strict"; | ||
case 'css': | ||
case 'local-css': | ||
return contents; | ||
@@ -118,0 +119,0 @@ default: |
{ | ||
"name": "esbuild-sass-plugin", | ||
"version": "3.1.0", | ||
"version": "3.2.0", | ||
"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", |
@@ -107,2 +107,23 @@ ![cooltext394785080075403](https://user-images.githubusercontent.com/160981/136289874-26ce7269-ea08-47dd-be31-9bf0ef7a0b8d.png) | ||
#### `type: "local-css"` | ||
This mode uses esbuild's built-in CSS modules support (i.e. the [`local-css` loader](https://esbuild.github.io/content-types/#local-css)). | ||
Use this for lightweight Sass integration that then leverages esbuild's [built-in CSS processing features](https://esbuild.github.io/content-types/#css): | ||
```javascript | ||
await esbuild.build({ | ||
... | ||
plugins: [ | ||
sassPlugin({ | ||
filter: /\.module\.scss$/, | ||
type: 'local-css' | ||
}), | ||
sassPlugin({ | ||
filter: /\.scss$/ | ||
type: 'css' | ||
}), | ||
], | ||
... | ||
}) | ||
``` | ||
#### `type: "style"` | ||
@@ -109,0 +130,0 @@ In this mode the stylesheet will be in the javascript bundle |
@@ -5,3 +5,3 @@ import {OnLoadResult} from 'esbuild' | ||
export type Type = 'css' | 'style' | 'css-text' | 'lit-css' | ((cssText: string, nonce?: string) => string) | ||
export type Type = 'css' | 'local-css' | 'style' | 'css-text' | 'lit-css' | ((cssText: string, nonce?: string) => string) | ||
@@ -8,0 +8,0 @@ export type SassPluginOptions = StringOptions<'sync'|'async'> & { |
@@ -121,5 +121,5 @@ import {OnLoadResult, Plugin} from 'esbuild' | ||
return type === 'css' ? { | ||
return type === 'css' || type === 'local-css' ? { | ||
contents: cssText, | ||
loader: 'css', | ||
loader: type, | ||
resolveDir, | ||
@@ -126,0 +126,0 @@ warnings, |
@@ -128,2 +128,3 @@ import {SassPluginOptions, Type} from './index' | ||
case 'css': | ||
case 'local-css': | ||
return contents | ||
@@ -130,0 +131,0 @@ default: |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
86901
1322
400