Skip to content

Commit

Permalink
Fix CSS Modules generated scope name based on prod vs dev mode. (#1749)
Browse files Browse the repository at this point in the history
  • Loading branch information
ashuverma authored Oct 29, 2020
1 parent 1989fdf commit 69d7751
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions packages/xarc-app/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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")) {
Expand Down

0 comments on commit 69d7751

Please sign in to comment.