esbuild-sass-plugin
Advanced tools
Comparing version 2.2.0 to 2.2.1
@@ -38,14 +38,13 @@ "use strict"; | ||
} | ||
const pluginName = 'sass-plugin'; | ||
return { | ||
name: pluginName, | ||
name: 'sass-plugin', | ||
setup({ initialOptions, onLoad }) { | ||
var _a; | ||
var _a, _b; | ||
const { sourcemap, watched } = (0, utils_1.getContext)(initialOptions); | ||
const renderSync = (0, render_1.createRenderer)(options, sourcemap); | ||
const renderSync = (0, render_1.createRenderer)(options, (_a = options.sourceMap) !== null && _a !== void 0 ? _a : sourcemap); | ||
const transform = options.transform; | ||
onLoad({ filter: (_a = options.filter) !== null && _a !== void 0 ? _a : DEFAULT_FILTER }, (0, cache_1.useCache)(options, async (path) => { | ||
onLoad({ filter: (_b = options.filter) !== null && _b !== void 0 ? _b : DEFAULT_FILTER }, (0, cache_1.useCache)(options, async (path) => { | ||
var _a; | ||
try { | ||
let { css, watchFiles } = renderSync(path); | ||
let { cssText, watchFiles } = renderSync(path); | ||
if (watched) { | ||
@@ -56,3 +55,3 @@ watched[path] = watchFiles; | ||
if (transform) { | ||
const out = await transform(css, resolveDir, path); | ||
const out = await transform(cssText, resolveDir, path); | ||
if (typeof out !== 'string') { | ||
@@ -68,7 +67,7 @@ return { | ||
else { | ||
css = out; | ||
cssText = out; | ||
} | ||
} | ||
return type === 'css' ? { | ||
contents: css, | ||
contents: cssText, | ||
loader: 'css', | ||
@@ -78,3 +77,3 @@ resolveDir, | ||
} : { | ||
contents: (0, utils_1.makeModule)(css, type), | ||
contents: (0, utils_1.makeModule)(cssText, type), | ||
loader: 'js', | ||
@@ -81,0 +80,0 @@ resolveDir, |
import { SassPluginOptions } from './index'; | ||
export declare type RenderSync = (path: string) => RenderResult; | ||
export declare type RenderResult = { | ||
css: string; | ||
cssText: string; | ||
watchFiles: string[]; | ||
}; | ||
export declare function createRenderer(options: SassPluginOptions | undefined, sourcemap: boolean): RenderSync; |
@@ -73,3 +73,3 @@ "use strict"; | ||
if (syntax === 'css') { | ||
return { css: (0, fs_1.readFileSync)(path, 'utf-8'), watchFiles: [path] }; | ||
return { cssText: (0, fs_1.readFileSync)(path, 'utf-8'), watchFiles: [path] }; | ||
} | ||
@@ -138,3 +138,3 @@ const { css, loadedUrls, sourceMap } = sass.compileString(source, { | ||
}); | ||
const cssText = css.toString(); | ||
let cssText = css.toString(); | ||
if (sourceMap) { | ||
@@ -146,5 +146,6 @@ sourceMap.sourceRoot = basedir; | ||
}); | ||
cssText += '\n' + (0, utils_1.sourceMappingURL)(sourceMap); | ||
} | ||
return { | ||
css: sourcemap ? `${cssText}\n${(0, utils_1.sourceMappingURL)(sourceMap)}` : cssText, | ||
cssText, | ||
watchFiles: [path, ...loadedUrls.map(url_1.fileURLToPath)] | ||
@@ -151,0 +152,0 @@ }; |
{ | ||
"name": "esbuild-sass-plugin", | ||
"version": "2.2.0", | ||
"version": "2.2.1", | ||
"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", |
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
44758