🚀 Big News: Socket Acquires Coana to Bring Reachability Analysis to Every Appsec Team.Learn more
Socket
DemoInstallSign in
Socket

vite-plugin-import-css-sheet

Package Overview
Dependencies
Maintainers
1
Versions
10
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

vite-plugin-import-css-sheet - npm Package Compare versions

Comparing version

to
1.0.5

5

dist/index.d.ts
import type { Plugin } from 'vite';
export declare const viteImportCssSheet: (transformers?: ((code: string, id: string) => string)[]) => Plugin;
export declare const viteImportCssSheet: (options?: Partial<{
additionalCode: string[];
transformers: ((code: string, id: string) => string)[];
}> | undefined) => Plugin;
//# sourceMappingURL=index.d.ts.map

35

dist/index.js
import { readFile as l } from "node:fs/promises";
const g = (r = []) => {
const c = /* @__PURE__ */ new Map(), d = [".ts", ".mts", ".js", ".mjs"], f = {
const v = (r) => {
const { transformers: d = [], additionalCode: f = [] } = r ?? {}, o = /* @__PURE__ */ new Map(), i = [".ts", ".mts", ".js", ".mjs"], h = {
"\\": "\\\\",
"`": "\\`",
$: "\\$"
}, h = (t) => new RegExp(t + `['"] *(?:with|assert) *{[(?:\r?
}, u = (t) => new RegExp(t + `['"] *(?:with|assert) *{[(?:\r?
) ]*type: *['"]css['"][(?:\r?
) ]*};`), i = (t) => {
) ]*};`), y = (t) => {
let e = "";
for (const s of t)
e += f[s] || s;
e += h[s] || s;
return `\`${e}\``;

@@ -22,7 +22,7 @@ };

const s = await this.resolve(t, e);
if (e = e == null ? void 0 : e.split("?")[0], s && d.some((n) => e == null ? void 0 : e.endsWith(n))) {
if (e = e == null ? void 0 : e.split("?")[0], s && i.some((n) => e == null ? void 0 : e.endsWith(n))) {
const n = await l(e, { encoding: "utf8" });
if (h(t).test(n)) {
const o = "\0virtual:" + t.replace(".css", ".stylesheet");
return c.set(o, s.id), o;
if (u(t).test(n)) {
const a = "\0virtual:" + t.replace(".css", ".stylesheet");
return o.set(a, s.id), a;
}

@@ -32,11 +32,14 @@ }

async load(t) {
if (!c.has(t))
if (!o.has(t))
return;
const e = c.get(t);
const e = o.get(t);
let s = await l(e, { encoding: "utf8" });
this.addWatchFile(e);
for (const a of r)
s = a(s, e);
return `const sheet = new CSSStyleSheet();
sheet.replaceSync(${i(s)});
for (const c of d)
s = c(s, e);
return `const styles = ${y(s)}
${f.join(`
`)}
const sheet = new CSSStyleSheet();
sheet.replaceSync(styles);
export default sheet;`;

@@ -47,4 +50,4 @@ }

export {
g as viteImportCssSheet
v as viteImportCssSheet
};
//# sourceMappingURL=index.js.map
{
"name": "vite-plugin-import-css-sheet",
"version": "1.0.4",
"version": "1.0.5",
"description": "Small plugin that enables the use of tc39/proposal-import-attributes for css files in vite.",

@@ -5,0 +5,0 @@ "license": "MIT",

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet