From 9958ad284eaba2abf69e373732d9b238493a12eb Mon Sep 17 00:00:00 2001 From: Ashu Verma Date: Wed, 28 Oct 2020 16:20:56 +0530 Subject: [PATCH] Fix CSS Modules generated scope name based on prod vs dev mode. --- packages/xarc-app/src/index.ts | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/packages/xarc-app/src/index.ts b/packages/xarc-app/src/index.ts index bdb67fc0d..a7d47f9d5 100644 --- a/packages/xarc-app/src/index.ts +++ b/packages/xarc-app/src/index.ts @@ -83,9 +83,10 @@ export function load( */ babelRegister?: any; /** - * if true, then load and setup CSS module runtime for node.js + * - boolean: if true, then load and setup CSS module runtime for node.js + * - object: options to be passed to cssModuleHook */ - cssModuleHook?: boolean; + cssModuleHook?: boolean | object; /** * if no CSS module hook, then a default ignore hook is load to avoid errors * when trying to load CSS modules. @@ -147,10 +148,10 @@ export function load( * https://github.com/webpack/css-loader#local-scope * https://github.com/css-modules/postcss-modules-scope */ - if (options.cssModuleHook === true) { + if (options.cssModuleHook === true || Object.keys(options.cssModuleHook).length > 0) { const opts = Object.assign( { - generateScopedName: "[name]__[local]___[hash:base64:5]", + generateScopedName: `${process.env.NODE_ENV === "production" ? "" : "[name]__[local]___"}[hash:base64:5]`, extensions: [".scss", ".styl", ".less", ".css"], preprocessCss: function(css, filename) { if (filename.endsWith(".styl")) {