From 91dc049c0f302b21705367a8cc5bc7574fd4d073 Mon Sep 17 00:00:00 2001 From: Marton Lederer Date: Sat, 20 Feb 2021 15:45:42 +0100 Subject: [PATCH] feat: update default class names --- src/index.ts | 38 ++++++++++++++++++++------------------ 1 file changed, 20 insertions(+), 18 deletions(-) diff --git a/src/index.ts b/src/index.ts index 77d8145..3824819 100644 --- a/src/index.ts +++ b/src/index.ts @@ -42,26 +42,28 @@ const postCSSPlugin = ({ // get a temporary path where we can save compiled CSS const tmpDirPath = tmp.dirSync().name, modulesMap: CSSModule[] = [], - pathMap: ModulePath[] = [], - modulesPlugin = postcssModules({ - ...(typeof modules !== "boolean" ? modules : {}), - getJSON(filepath, json, outpath) { - const tmpFilePath = pathMap.find( - ({ originalPath }) => originalPath === filepath - ).temporaryPath; + pathMap: ModulePath[] = []; - modulesMap.push({ - path: tmpFilePath, - map: json - }); + const modulesPlugin = postcssModules({ + generateScopedName: "[name]__[local]___[hash:base64:5]", + ...(typeof modules !== "boolean" ? modules : {}), + getJSON(filepath, json, outpath) { + const tmpFilePath = pathMap.find( + ({ originalPath }) => originalPath === filepath + ).temporaryPath; - if ( - typeof modules !== "boolean" && - typeof modules.getJSON === "function" - ) - return modules.getJSON(filepath, json, outpath); - } - }); + modulesMap.push({ + path: tmpFilePath, + map: json + }); + + if ( + typeof modules !== "boolean" && + typeof modules.getJSON === "function" + ) + return modules.getJSON(filepath, json, outpath); + } + }); build.onResolve( { filter: /.\.(css|sass|scss|less|styl)$/, namespace: "file" },