node-css-require
Advanced tools
Comparing version 0.1.3 to 0.1.4
@@ -0,1 +1,3 @@ | ||
import { AcceptedPlugin } from 'postcss'; | ||
export type { AcceptedPlugin } from 'postcss'; | ||
export interface CompileCssResult { | ||
@@ -5,4 +7,8 @@ css: string; | ||
} | ||
export declare function compileCss(code: string, filename: string): CompileCssResult; | ||
export interface CompileCssConfiguration { | ||
plugins?: AcceptedPlugin[]; | ||
generateScopedName?: string; | ||
} | ||
export declare function compileCss(code: string, filename: string, config?: CompileCssConfiguration): CompileCssResult; | ||
export declare const register: () => void; | ||
//# sourceMappingURL=nodeCssRequire.d.ts.map |
@@ -12,7 +12,7 @@ "use strict"; | ||
const register_1 = require("@swc-node/register/register"); | ||
function compileCss(code, filename) { | ||
function compileCss(code, filename, config) { | ||
let exportedTokens = {}; | ||
const res = (0, postcss_1.default)([ | ||
const plugins = [ | ||
(0, postcss_modules_sync_1.default)({ | ||
generateScopedName: '[path][local]-[hash:base64:10]', | ||
generateScopedName: (config === null || config === void 0 ? void 0 : config.generateScopedName) || '[path][local]-[hash:base64:10]', | ||
getJSON: (tokens) => { | ||
@@ -22,3 +22,7 @@ exportedTokens = tokens; | ||
}), | ||
]).process(code, { from: filename }); | ||
]; | ||
if (config === null || config === void 0 ? void 0 : config.plugins) { | ||
plugins.push(...config.plugins); | ||
} | ||
const res = (0, postcss_1.default)(plugins).process(code, { from: filename }); | ||
// the below is required to properly resolve `exportedTokens` | ||
@@ -25,0 +29,0 @@ res |
{ | ||
"name": "node-css-require", | ||
"version": "0.1.3", | ||
"version": "0.1.4", | ||
"description": "Load CSS modules when running Node.js CLI and server applications", | ||
@@ -42,5 +42,5 @@ "keywords": [ | ||
"devDependencies": { | ||
"@goldstack/utils-git": "0.1.36", | ||
"@types/jest": "^27.5.1", | ||
"@types/node": "^17.0.33", | ||
"@goldstack/utils-git": "0.1.37", | ||
"@types/jest": "^28.1.8", | ||
"@types/node": "^18.7.13", | ||
"jest": "^28.1.0", | ||
@@ -47,0 +47,0 @@ "rimraf": "^3.0.2", |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
7842
63