Skip to content

Commit 3dfdca9

Browse files
author
Alexey Litvinov
committed
devMode
1 parent bddbf22 commit 3dfdca9

File tree

3 files changed

+9
-3
lines changed

3 files changed

+9
-3
lines changed

lib/index.js

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ const debugFetch = require('debug')('css-modules:fetch');
2121
const debugSetup = require('debug')('css-modules:setup');
2222

2323
module.exports = function setupHook({
24+
devMode,
2425
extensions = '.css',
2526
ignore,
2627
preprocessCss = identity,
@@ -39,6 +40,11 @@ module.exports = function setupHook({
3940

4041
const tokensByFile = {};
4142

43+
// debug option is preferred NODE_ENV === 'development'
44+
const debugMode = typeof devMode !== 'undefined'
45+
? devMode
46+
: process.env.NODE_ENV === 'development';
47+
4248
let scopedName;
4349
if (generateScopedName) {
4450
scopedName = typeof generateScopedName !== 'function'
@@ -67,8 +73,6 @@ module.exports = function setupHook({
6773
// https://github.com/postcss/postcss#options
6874
const runner = postcss(plugins);
6975

70-
// https://github.com/postcss/postcss/blob/master/docs/api.md#processorprocesscss-opts
71-
7276
/**
7377
* @todo think about replacing sequential fetch function calls with requires calls
7478
* @param {string} _to
@@ -99,7 +103,7 @@ module.exports = function setupHook({
99103

100104
tokens = lazyResult.root.tokens;
101105

102-
if (process.env.NODE_ENV !== 'development') {
106+
if (!debugMode) {
103107
// updating cache
104108
tokensByFile[filename] = tokens;
105109
} else {

lib/validate.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ const keys = require('lodash').keys;
44

55
const rules = {
66
// hook
7+
devMode: 'boolean',
78
extensions: 'array|string',
89
ignore: 'function|regex|string',
910
preprocessCss: 'function',
@@ -21,6 +22,7 @@ const rules = {
2122

2223
const tests = {
2324
array: require('lodash').isArray,
25+
boolean: require('lodash').isBoolean,
2426
function: require('lodash').isFunction,
2527
regex: require('lodash').isRegExp,
2628
string: require('lodash').isString,

test/api/devMode.js

Whitespace-only changes.

0 commit comments

Comments
 (0)