From 5ab86606da89908916813d2cd12215fdba28f6b4 Mon Sep 17 00:00:00 2001 From: Christophe Massolin Date: Fri, 30 Sep 2022 16:46:55 +0200 Subject: [PATCH] add usePascalCase option --- lib/plugin.js | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/lib/plugin.js b/lib/plugin.js index 14d7fcc..5f1d410 100644 --- a/lib/plugin.js +++ b/lib/plugin.js @@ -18,6 +18,7 @@ const { } = require('./utils.js'); const cssHandler = require('@parcel/css'); const camelCase = require('lodash/camelCase'); +const upperFirst = require('lodash/upperFirst'); const BuildCache = require('./cache.js'); /** @@ -58,7 +59,13 @@ const buildCssModulesJs = async ({ fullPath, options, build }) => { .sort() // to keep order consistent in different builds .forEach((originClass) => { const patchedClass = exports[originClass].name; - cssModulesJSON[camelCase(originClass)] = patchedClass; + let name = camelCase(originClass); + + if (options.usePascalCase) { + name = upperFirst(name) + } + + cssModulesJSON[name] = patchedClass; }); const classNamesMapString = JSON.stringify(cssModulesJSON);