esbuild-sass-plugin
Advanced tools
Comparing version 2.2.5 to 2.2.6
@@ -25,3 +25,3 @@ "use strict"; | ||
} | ||
const nonce = options.nonce; | ||
const nonce = (0, utils_1.parseNonce)(options.nonce); | ||
return { | ||
@@ -28,0 +28,0 @@ name: 'sass-plugin', |
@@ -20,2 +20,3 @@ import { SassPluginOptions, Type } from "./index"; | ||
export declare function makeModule(contents: string, type: Type, nonce?: string): string; | ||
export declare function parseNonce(nonce: string | undefined): string | undefined; | ||
export declare type PostcssModulesParams = Parameters<PostcssModulesPlugin>[0] & { | ||
@@ -22,0 +23,0 @@ basedir?: string; |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.postcssModules = exports.makeModule = exports.sourceMappingURL = exports.getContext = exports.fileSyntax = exports.modulesPaths = exports.RELATIVE_PATH = void 0; | ||
exports.postcssModules = exports.parseNonce = exports.makeModule = exports.sourceMappingURL = exports.getContext = exports.fileSyntax = exports.modulesPaths = exports.RELATIVE_PATH = void 0; | ||
const path_1 = require("path"); | ||
@@ -94,3 +94,3 @@ const fs_1 = require("fs"); | ||
const style = document.createElement("style"); | ||
style.setAttribute("nonce", "${nonce}"); | ||
style.setAttribute("nonce", ${nonce}); | ||
style.appendChild(document.createTextNode(css)); | ||
@@ -115,2 +115,16 @@ document.head.appendChild(style); | ||
exports.makeModule = makeModule; | ||
function parseNonce(nonce) { | ||
if (nonce) { | ||
if (nonce.startsWith("window.") || nonce.startsWith("process.") || nonce.startsWith("globalThis.")) { | ||
return nonce; | ||
} | ||
else { | ||
return JSON.stringify(nonce); | ||
} | ||
} | ||
else { | ||
return nonce; | ||
} | ||
} | ||
exports.parseNonce = parseNonce; | ||
function postcssModules(options, plugins = []) { | ||
@@ -117,0 +131,0 @@ const postcss = requireTool('postcss', options.basedir); |
{ | ||
"name": "esbuild-sass-plugin", | ||
"version": "2.2.5", | ||
"version": "2.2.6", | ||
"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", |
@@ -139,2 +139,15 @@ ![cooltext394785080075403](https://user-images.githubusercontent.com/160981/136289874-26ce7269-ea08-47dd-be31-9bf0ef7a0b8d.png) | ||
If the `nonce` string is a field access starting with `window`, `process` or `globalThis` it is left in the code without quotes. | ||
```javascript | ||
sassPlugin({ | ||
type: 'style', | ||
nonce: 'window.__esbuild_nonce__' | ||
}) | ||
``` | ||
This allows to define it globally or to leave it for a subsequent build to resolve it using [esbuild define](https://esbuild.github.io/api/#define). | ||
```javascript | ||
define: {'window.__esbuild_nonce__': '"12345"'} | ||
``` | ||
### `importMapper` | ||
@@ -141,0 +154,0 @@ |
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
47213
511
307