File tree Expand file tree Collapse file tree 3 files changed +9
-3
lines changed Expand file tree Collapse file tree 3 files changed +9
-3
lines changed Original file line number Diff line number Diff line change @@ -21,6 +21,7 @@ const debugFetch = require('debug')('css-modules:fetch');
2121const debugSetup = require ( 'debug' ) ( 'css-modules:setup' ) ;
2222
2323module . 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 {
Original file line number Diff line number Diff line change @@ -4,6 +4,7 @@ const keys = require('lodash').keys;
44
55const 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
2223const 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 ,
You can’t perform that action at this time.
0 commit comments