@zohodesk/react-cli 1.1.10 → 1.1.11-exp.2

Sign up to get free protection for your applications and to get access to all the features.
package/README.md CHANGED
@@ -44,6 +44,66 @@ Now to run app
44
44
 
45
45
  # Change Logs
46
46
 
47
+ # 1.1.11-exp.2 (11-8-2023)
48
+
49
+ **Changes**
50
+ - Added more customization support for `stats.json` output.
51
+ - Disabling `bundle-analyser` stats report for our customized stats output based on a flag.
52
+
53
+ # 1.1.11-exp.1 (8-8-2023)
54
+
55
+ **Changes**
56
+
57
+ - Added a new config `stats` to control stats file generation.
58
+
59
+ **Features:-**
60
+
61
+ - Generating stats.json file for the build assets only in production mode. To use this feature we need to add `stats > enable` or cli flags `enable_stats`.
62
+
63
+ # 1.1.11 (4-8-2023)
64
+
65
+ **Changes**
66
+
67
+ - we have renamed our default config file as `react-cli.config.js` instead of `build.config.js`. But we still support `build.config.js` we will remove it in later major version.
68
+
69
+ - Prop-type, Prop description, Default Props support for docs given.
70
+ - Docs and Docs_Code UI updated.
71
+
72
+ **Features:-**
73
+
74
+ - custom classname prefix for separate packages now supported.
75
+ - to use custom classnames for specific patterns, we use the following pattern in `app > customClassNamePrefix` or `docs > customClassNamePrefix` :
76
+
77
+ ```
78
+ "customClassNamePrefix" : [
79
+ {
80
+ "enable": true,
81
+ "prefix": "[required-prefix]",
82
+ "patterns":[
83
+ "**/[path-name]/**/*.css"
84
+ ]
85
+ }
86
+ ]
87
+ ```
88
+
89
+ For example,
90
+
91
+ ```
92
+ "customClassNamePrefix": [
93
+ {
94
+ "enable": true,
95
+ "prefix": "zdSvg",
96
+ "patterns": [
97
+ "**/@zohodesk/svg/**/*.css"
98
+ ]
99
+ },
100
+ ],
101
+ ```
102
+
103
+ **Issue Fix:**
104
+
105
+ - typo fix, (../src/common/runPreProcess.js) to (../lib/common/runPreProcess.js) in cli.js our code.
106
+
47
107
  # 1.1.10 (2-8-2023)
48
108
 
49
109
  **Issue Fix:**
@@ -213,8 +273,8 @@ Now to run app
213
273
 
214
274
  **Breaking Changes:**
215
275
 
216
- - We have remove ssl certificate for security reasons.
217
- So default https server won't run.
276
+ - We have remove ssl certificate for security reasons.
277
+ So default https server won't run.
218
278
  In order to make it work as before you need to specify two things
219
279
  1. install `@zohodesk-private/client_dev_cert`
220
280
  2. `react-cli.app.server.httpsCerts` option example `"httpsCerts": "@zohodesk-private/client_dev_cert"`
@@ -230,8 +290,8 @@ Now to run app
230
290
 
231
291
  **Breaking Changes:**
232
292
 
233
- - We have remove ssl certificate for security reasons.
234
- So default https server won't run.
293
+ - We have remove ssl certificate for security reasons.
294
+ So default https server won't run.
235
295
  In order to make it work as before you need to specify two things
236
296
  1. install `@zohodesk-private/client_dev_cert`
237
297
  2. `react-cli.app.server.httpsCerts` option example `"httpsCerts": "@zohodesk-private/client_dev_cert"`
@@ -248,8 +308,8 @@ Now to run app
248
308
 
249
309
  **Breaking Changes:**
250
310
 
251
- - We have remove ssl certificate for security reasons.
252
- So default https server won't run.
311
+ - We have remove ssl certificate for security reasons.
312
+ So default https server won't run.
253
313
  In order to make it work as before you need to specify two things
254
314
  1. install `@zohodesk-private/client_dev_cert`
255
315
  2. `react-cli.app.server.httpsCerts` option example `"httpsCerts": "@zohodesk-private/client_dev_cert"`
@@ -315,8 +375,8 @@ cli has been updated to fix compose issue faced when classname:hover exists and
315
375
 
316
376
  **Feature:-**
317
377
 
318
- - `react-cli.test.classnameFormat` option added to change CssModules (Ex: import style from "./a.module.css" ) className transform template unittest case.
319
- `classnameFormat` default value `[classname]` you can customize it. Example: `[classname]-[hash]`
378
+ - `react-cli.test.classnameFormat` option added to change CssModules (Ex: import style from "./a.module.css" ) className transform template unittest case.
379
+ `classnameFormat` default value `[classname]` you can customize it. Example: `[classname]-[hash]`
320
380
 
321
381
  **Changes:-**
322
382
 
@@ -335,7 +395,7 @@ For an more information and reference, refer to `[details](https://zgit.csez.zoh
335
395
 
336
396
  # 0.0.1-beta.172
337
397
 
338
- We have renamed some options, For Our future features convenience.
398
+ We have renamed some options, For Our future features convenience.
339
399
  We have given fallback support.
340
400
  Deprecation Warnings:-
341
401
 
@@ -413,7 +473,7 @@ Features:-
413
473
 
414
474
  # 0.0.1-beta.167.1
415
475
 
416
- In this version we merged changes from [0.0.1-betaa.138.1](#0.0.1-betaa.138.1).
476
+ In this version we merged changes from [0.0.1-betaa.138.1](#0.0.1-betaa.138.1).
417
477
  and with [0.0.1-beta.167](#0.0.1-beta.167) version changes.
418
478
 
419
479
  # 0.0.1-beta.167
@@ -1321,3 +1381,7 @@ impact servise related changes:-
1321
1381
  - prod string error fix
1322
1382
  - efc build support
1323
1383
  - single style tag support
1384
+
1385
+ ```
1386
+
1387
+ ```
package/bin/cli.js CHANGED
@@ -6,7 +6,7 @@ const getOptions = require('../lib/utils/getOptions.js').default;
6
6
 
7
7
  const { log } = require('../lib/utils/log.js');
8
8
  const { getCliPath } = require('../lib/servers/getCliPath.js');
9
- const { runPreProcess } = require('../src/common/runPreProcess.js');
9
+ const { runPreProcess } = require('../lib/common/runPreProcess.js');
10
10
  //initPreCommitHook();
11
11
 
12
12
  const [, , option] = process.argv;
@@ -1,16 +1,21 @@
1
1
  "use strict";
2
2
 
3
- const path = require('path');
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.runPreProcess = runPreProcess;
4
7
 
5
- const {
6
- existsSync
7
- } = require('fs');
8
+ var _path = _interopRequireWildcard(require("path"));
8
9
 
9
- const {
10
- spawn
11
- } = require('child_process');
10
+ var _fs = require("fs");
12
11
 
13
- exports.runPreProcess = function runPreProcess({
12
+ var _child_process = require("child_process");
13
+
14
+ function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
15
+
16
+ function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
17
+
18
+ function runPreProcess({
14
19
  options,
15
20
  option,
16
21
  nodemon,
@@ -19,17 +24,17 @@ exports.runPreProcess = function runPreProcess({
19
24
  const {
20
25
  preprocess
21
26
  } = options;
22
- const preprocessorPath = preprocess.runner ? path.join(process.cwd(), preprocess.runner) : '';
27
+ const preprocessorPath = preprocess.runner ? _path.default.join(process.cwd(), preprocess.runner) : '';
23
28
  const preprocessCli = preprocess.stopNodemon ? 'node' : nodemon;
24
29
 
25
- if (preprocessorPath && existsSync(preprocessorPath)) {
26
- const preprocessorDirPath = path.dirname(preprocessorPath);
30
+ if (preprocessorPath && (0, _fs.existsSync)(preprocessorPath)) {
31
+ const preprocessorDirPath = (0, _path.dirname)(preprocessorPath);
27
32
  const watchOptions = preprocessCli === nodemon ? ['--watch', preprocessorDirPath] : []; // eslint-disable-next-line default-case
28
33
 
29
34
  switch (option) {
30
35
  case 'start':
31
36
  case 'docs':
32
- spawn(preprocessCli, [preprocessorPath, ...watchOptions], {
37
+ (0, _child_process.spawn)(preprocessCli, [preprocessorPath, ...watchOptions], {
33
38
  stdio: 'inherit',
34
39
  cwd: preprocessorDirPath
35
40
  }); // NOTE: it's ok if we not close this here
@@ -53,7 +58,7 @@ exports.runPreProcess = function runPreProcess({
53
58
  {
54
59
  const result = spawnSync(preprocessCli, [preprocessorPath, ...watchOptions], {
55
60
  stdio: 'inherit',
56
- cwd: path.dirname(preprocessorPath)
61
+ cwd: preprocessorDirPath
57
62
  });
58
63
  process.exit(result.status);
59
64
  break;
@@ -63,4 +68,4 @@ exports.runPreProcess = function runPreProcess({
63
68
  console.error(`preProcessor not exists ${preprocessorPath}`);
64
69
  process.exit(0);
65
70
  }
66
- };
71
+ }
@@ -23,7 +23,8 @@ let {
23
23
  folder,
24
24
  publicPath,
25
25
  cssHashSelectors,
26
- classNamePrefix
26
+ classNamePrefix,
27
+ customClassNamePrefix
27
28
  }
28
29
  },
29
30
  packageVersion
@@ -83,7 +84,7 @@ module.exports = {
83
84
  loader: 'css-loader',
84
85
  options: {
85
86
  modules: {
86
- getLocalIdent: (0, _cssClassNameGenerate.default)(cssUniqueness, cssHashSelectors, classNamePrefix)
87
+ getLocalIdent: (0, _cssClassNameGenerate.default)(cssUniqueness, cssHashSelectors, classNamePrefix, customClassNamePrefix)
87
88
  }
88
89
  }
89
90
  }]
@@ -30,6 +30,7 @@ const {
30
30
  cssVariableReplacementConfig,
31
31
  selectorWeightConfig,
32
32
  cssUniqueness,
33
+ customClassNamePrefix,
33
34
  seperateCssModules,
34
35
  changeRuntimeChunkChar,
35
36
  // we are going to use this for fonts file name collide in issue in devmode
@@ -108,6 +109,7 @@ module.exports = {
108
109
  mediaQueryHoverActiveString,
109
110
  cssVariableReplacementConfig,
110
111
  selectorWeightConfig,
112
+ customClassNamePrefix,
111
113
  classNameBlob: '[local]',
112
114
  cssUniqueness: false,
113
115
  selectorReplace: null,
@@ -124,6 +126,7 @@ module.exports = {
124
126
  selectorWeightConfig,
125
127
  classNameBlob: null,
126
128
  cssUniqueness,
129
+ customClassNamePrefix,
127
130
  selectorReplace,
128
131
  cssHashSelectors,
129
132
  classNamePrefix,
@@ -20,6 +20,7 @@ const {
20
20
  componentFolder,
21
21
  enableChunkHash,
22
22
  cssUniqueness,
23
+ customClassNamePrefix,
23
24
  plugins,
24
25
  exclude,
25
26
  patterns,
@@ -86,6 +87,7 @@ module.exports = isSSTest => ({
86
87
  selectorWeightConfig,
87
88
  classNameBlob: false,
88
89
  cssUniqueness,
90
+ customClassNamePrefix,
89
91
  selectorReplace,
90
92
  cssHashSelectors,
91
93
  classNamePrefix,
@@ -19,6 +19,7 @@ const {
19
19
  docs: {
20
20
  componentFolder,
21
21
  cssUniqueness,
22
+ customClassNamePrefix,
22
23
  plugins,
23
24
  exclude,
24
25
  patterns,
@@ -85,6 +86,7 @@ module.exports = {
85
86
  selectorWeightConfig,
86
87
  classNameBlob: false,
87
88
  cssUniqueness,
89
+ customClassNamePrefix,
88
90
  selectorReplace: null,
89
91
  cssHashSelectors,
90
92
  classNamePrefix,
@@ -34,6 +34,7 @@ const {
34
34
  cssVariableReplacementConfig,
35
35
  selectorWeightConfig,
36
36
  cssUniqueness,
37
+ customClassNamePrefix,
37
38
  server: {
38
39
  mode
39
40
  },
@@ -161,6 +162,7 @@ module.exports = {
161
162
  mediaQueryHoverActiveString,
162
163
  classNameBlob: '[local]',
163
164
  cssUniqueness: false,
165
+ customClassNamePrefix,
164
166
  selectorReplace: null,
165
167
  postCssPluginOrder
166
168
  })
@@ -175,6 +177,7 @@ module.exports = {
175
177
  selectorWeightConfig,
176
178
  classNameBlob: false,
177
179
  cssUniqueness,
180
+ customClassNamePrefix,
178
181
  selectorReplace,
179
182
  cssHashSelectors,
180
183
  classNamePrefix,
@@ -44,7 +44,8 @@ const getCSSLoaders = optionsObj => {
44
44
  selectorReplace,
45
45
  cssHashSelectors,
46
46
  classNamePrefix,
47
- postCssPluginOrder
47
+ postCssPluginOrder,
48
+ customClassNamePrefix
48
49
  } = optionsObj;
49
50
  const {
50
51
  devCssFileBountry
@@ -65,7 +66,7 @@ const getCSSLoaders = optionsObj => {
65
66
  if (classNameBlob) {
66
67
  cssLoaderOptions.modules.localIdentName = classNameBlob;
67
68
  } else {
68
- cssLoaderOptions.modules.getLocalIdent = (0, _cssClassNameGenerate.default)(cssUniqueness, cssHashSelectors, classNamePrefix, patterns);
69
+ cssLoaderOptions.modules.getLocalIdent = (0, _cssClassNameGenerate.default)(cssUniqueness, cssHashSelectors, classNamePrefix, customClassNamePrefix, patterns);
69
70
  }
70
71
 
71
72
  const pluginOrder = calculatePostCssPluginOrder(postCssPluginOrder, Object.keys(plugins).filter(x => plugins[x] === true)); // console.log('selector weight config : ', selectorWeightConfig);
package/lib/logger.js CHANGED
@@ -5,8 +5,10 @@ Object.defineProperty(exports, "__esModule", {
5
5
  });
6
6
  exports.errorLogger = errorLogger;
7
7
  exports.messageLogger = messageLogger;
8
+ exports.verboseLogger = verboseLogger;
8
9
  exports.warnLogger = warnLogger;
9
10
 
11
+ /* eslint-disable no-console */
10
12
  function messageLogger(...args) {
11
13
  console.log(...args);
12
14
  }
@@ -17,4 +19,9 @@ function errorLogger(...args) {
17
19
 
18
20
  function warnLogger(...args) {
19
21
  console.warn(...args);
22
+ }
23
+
24
+ function verboseLogger(...args) {
25
+ // TODO: need to be remove when publish happens
26
+ process.env.VERBOSE === 'true' && console.log('\x1b[33m [verbose] \x1b[0m', ...args);
20
27
  }
@@ -35,6 +35,8 @@ var _RtlCssPlugin = require("../plugins/RtlSplitPlugin/RtlCssPlugin");
35
35
 
36
36
  var _configHtmlWebpackPlugins = require("./configHtmlWebpackPlugins");
37
37
 
38
+ var _StatsPlugin = _interopRequireDefault(require("../plugins/StatsPlugin"));
39
+
38
40
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
39
41
 
40
42
  // eslint-disable-next-line no-unused-vars
@@ -88,6 +90,12 @@ const getProdPlugins = (options, publicPath = '') => {
88
90
  templateFilePath,
89
91
  localeAttr: efcLocaleAttr
90
92
  } = options.efc;
93
+ const {
94
+ enable: enableStats,
95
+ options: statsOptions,
96
+ excludeKeys: statsOutputExcludeKeys,
97
+ fileName: statsFileName
98
+ } = options.stats;
91
99
  const hasEFC = newOptionForEnableEFC || prevOptionForEnableEFC;
92
100
  const hashTempalate = enableChunkHash ? '.[chunkhash:20]_' : '';
93
101
  const cssLTRFileNameTempalte = `css/[name]${hashTempalate}${enableRTLSplit ? '.ltr' : ''}.css`;
@@ -227,9 +235,9 @@ const getProdPlugins = (options, publicPath = '') => {
227
235
  if (bundleAnalyze) {
228
236
  pluginsArr.push(new _webpackBundleAnalyzer.BundleAnalyzerPlugin({
229
237
  analyzerMode: 'static',
230
- generateStatsFile: true,
238
+ generateStatsFile: !enableStats,
231
239
  openAnalyzer: false,
232
- statsOptions: {
240
+ statsOptions: enableStats ? null : {
233
241
  source: false,
234
242
  normal: true,
235
243
  chunks: false,
@@ -288,6 +296,11 @@ const getProdPlugins = (options, publicPath = '') => {
288
296
 
289
297
 
290
298
  customAttributes.enable && pluginsArr.push(new _CustomAttributePlugin.CustomAttributePlugin(customAttributes));
299
+ enableStats && pluginsArr.push(new _StatsPlugin.default({
300
+ statsOptions,
301
+ statsOutputExcludeKeys,
302
+ statsFileName
303
+ }));
291
304
  return pluginsArr;
292
305
  };
293
306
 
@@ -0,0 +1,174 @@
1
+ "use strict";
2
+
3
+ const fs = require('fs');
4
+
5
+ const path = require('path');
6
+
7
+ const {
8
+ Readable
9
+ } = require('stream');
10
+
11
+ const pluginName = 'stats-plugin';
12
+ const statsSchema = {
13
+ all: false,
14
+ children: false,
15
+ source: false,
16
+ assets: true,
17
+ chunks: true,
18
+ chunkGroups: true,
19
+ chunkOrigins: true,
20
+ chunkModules: true,
21
+ entrypoints: true,
22
+ modules: true,
23
+ moduleTrace: true,
24
+ outputPath: true,
25
+ performance: true,
26
+ reasons: true
27
+ };
28
+
29
+ class StatsPlugin {
30
+ constructor({
31
+ statsOptions = {},
32
+ statsOutputExcludeKeys = [],
33
+ statsFileName = 'stats.json'
34
+ }) {
35
+ this.excludeKeysInStat = statsOutputExcludeKeys;
36
+ this.statsOptions = Object.assign({}, statsSchema, statsOptions);
37
+ this.statsFileName = statsFileName;
38
+ }
39
+
40
+ apply(compiler) {
41
+ compiler.hooks.done.tap(pluginName, stats => {
42
+ const statsJson = stats.toJson(this.statsOptions);
43
+ this.emitStats(statsJson);
44
+ });
45
+ }
46
+
47
+ transform(statsJson) {
48
+ return Object.keys(statsJson).reduce((acc, cur) => {
49
+ if (this.excludeKeysInStat.includes(cur)) {
50
+ return acc;
51
+ }
52
+
53
+ acc[cur] = statsJson[cur];
54
+ return acc;
55
+ }, {});
56
+ }
57
+
58
+ emitStats(statsJson) {
59
+ const {
60
+ outputPath
61
+ } = statsJson;
62
+ const transformedStatsJson = this.transform(statsJson);
63
+ const stringifiedJson = typeof statsJson === 'object' ? JSON.stringify(transformedStatsJson) : transformedStatsJson;
64
+ fs.writeFile(path.join(outputPath, this.statsFileName), stringifiedJson, err => {
65
+ if (err) {
66
+ throw err;
67
+ }
68
+ });
69
+ }
70
+
71
+ } // class StatsSerializeStream extends Readable {
72
+ // constructor(stats) {
73
+ // super();
74
+ // this._indentLevel = 0;
75
+ // this._stringifier = this._stringify(stats);
76
+ // }
77
+ // get _indent() {
78
+ // return ' '.repeat(this._indentLevel);
79
+ // }
80
+ // _read() {
81
+ // let readMore = true;
82
+ // while (readMore) {
83
+ // const { value, done } = this._stringifier.next();
84
+ // if (done) {
85
+ // this.push(null);
86
+ // readMore = false;
87
+ // } else {
88
+ // readMore = this.push(value);
89
+ // }
90
+ // }
91
+ // }
92
+ // *_stringify(obj) {
93
+ // if (
94
+ // typeof obj === 'string' ||
95
+ // typeof obj === 'number' ||
96
+ // typeof obj === 'boolean' ||
97
+ // obj === null
98
+ // ) {
99
+ // yield JSON.stringify(obj);
100
+ // } else if (Array.isArray(obj)) {
101
+ // yield '[';
102
+ // this._indentLevel++;
103
+ // let isFirst = true;
104
+ // for (let item of obj) {
105
+ // if (item === undefined) {
106
+ // item = null;
107
+ // }
108
+ // yield `${isFirst ? '' : ','}\n${this._indent}`;
109
+ // yield* this._stringify(item);
110
+ // isFirst = false;
111
+ // }
112
+ // this._indentLevel--;
113
+ // yield obj.length ? `\n${this._indent}]` : ']';
114
+ // } else {
115
+ // yield '{';
116
+ // this._indentLevel++;
117
+ // let isFirst = true;
118
+ // const entries = Object.entries(obj);
119
+ // for (const [itemKey, itemValue] of entries) {
120
+ // if (itemValue === undefined) {
121
+ // continue;
122
+ // }
123
+ // yield `${isFirst ? '' : ','}\n${this._indent}${JSON.stringify(
124
+ // itemKey
125
+ // )}: `;
126
+ // yield* this._stringify(itemValue);
127
+ // isFirst = false;
128
+ // }
129
+ // this._indentLevel--;
130
+ // yield entries.length ? `\n${this._indent}}` : '}';
131
+ // }
132
+ // }
133
+ // }
134
+ // function writeStats(stats, filepath) {
135
+ // return new Promise((resolve, reject) => {
136
+ // new StatsSerializeStream(stats)
137
+ // .on('end', resolve)
138
+ // .on('error', reject)
139
+ // .pipe(fs.createWriteStream(filepath));
140
+ // });
141
+ // }
142
+ // class StatsStremPlugin {
143
+ // constructor({ statsOptions = {}, statsOutputExcludeKeys = [] }) {
144
+ // this.excludeKeysInStat = statsOutputExcludeKeys;
145
+ // this.statsOptions = Object.assign({}, statsSchema, statsOptions);
146
+ // }
147
+ // apply(compiler) {
148
+ // compiler.hooks.done.tap(pluginName, stats => {
149
+ // const statsJson = stats.toJson(this.statsOptions);
150
+ // this.emitStats(statsJson);
151
+ // });
152
+ // }
153
+ // transform(statsJson) {
154
+ // return Object.keys(statsJson).reduce((acc, cur) => {
155
+ // if (this.excludeKeysInStat.includes(cur)) {
156
+ // return acc;
157
+ // }
158
+ // acc[cur] = statsJson[cur];
159
+ // return acc;
160
+ // }, {});
161
+ // }
162
+ // emitStats(statsJson) {
163
+ // const { outputPath } = statsJson;
164
+ // const transformedStatsJson = this.transform(statsJson);
165
+ // // const stringifiedJson =
166
+ // // typeof statsJson === 'object'
167
+ // // ? JSON.stringify(transformedStatsJson)
168
+ // // : transformedStatsJson;
169
+ // writeStats(transformedStatsJson, outputPath + 'jos-stats.json');
170
+ // }
171
+ // }
172
+
173
+
174
+ module.exports = StatsPlugin;
@@ -15,7 +15,6 @@ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { de
15
15
 
16
16
  // TODO move deprecated options to separate file and manage seperately
17
17
  var _default = {
18
- cliRootPath: null,
19
18
  unstableDepsInverse: {
20
19
  value: false,
21
20
  cli: 'unstable_deps_inverse'
@@ -130,6 +129,7 @@ var _default = {
130
129
  value: '@zohodesk/client_packages_group',
131
130
  cli: 'module_resolve_path'
132
131
  },
132
+ customClassNamePrefix: [],
133
133
  // this option only for impact testing
134
134
  devCssFileBountry: {
135
135
  value: '',
@@ -357,6 +357,7 @@ var _default = {
357
357
  hover: 'all and (min--moz-device-pixel-ratio:0) and (hover: hover), (hover: hover)',
358
358
  none: '(hover: none)'
359
359
  },
360
+ customClassNamePrefix: [],
360
361
  componentFolder: 'src',
361
362
  cssUniqueness: {
362
363
  value: true,
@@ -722,6 +723,14 @@ var _default = {
722
723
  cli: 'module_mode'
723
724
  },
724
725
  disableES5Transpile: true
726
+ },
727
+ stats: {
728
+ enable: {
729
+ value: false,
730
+ cli: 'enable_stats'
731
+ },
732
+ fileName: undefined,
733
+ options: undefined
725
734
  }
726
735
  };
727
736
  exports.default = _default;
@@ -38,14 +38,35 @@ const isSelectorPackage = (resourcePath, packages) => {
38
38
  return isValid;
39
39
  };
40
40
 
41
+ function patternBasedClass({
42
+ customClassNamePrefix,
43
+ context,
44
+ relativePath,
45
+ localName
46
+ }) {
47
+ let newName = null;
48
+ customClassNamePrefix.forEach(obj => {
49
+ if (obj.enable) {
50
+ if (obj.patterns && obj.prefix && (0, _fileHandling.isFileNameMatchingPluginPattern)({
51
+ filename: context.resourcePath,
52
+ filterArr: obj.patterns
53
+ })) {
54
+ const h = (0, _getHash.default)(`${relativePath}-${localName}`, 10);
55
+ newName = `${obj.prefix}${h}`;
56
+ }
57
+ }
58
+ });
59
+ return newName;
60
+ }
61
+
41
62
  var _default = (unique = true, {
42
63
  filenames,
43
64
  packages
44
- }, classNamePrefix, patterns) => (context, localIdentName, localName) => {
65
+ }, classNamePrefix, customClassNamePrefix, patterns) => (context, localIdentName, localName) => {
45
66
  // console.log(patterns, context.resourcePath);
46
- // NOTE: in build macine we use date as folder path.
67
+ // NOTE: in build machine we use date as folder path.
47
68
  // So every time we create new build there is path will alway different
48
- // in order to minmaze that problem we try in relative path;
69
+ // in order to minimize that problem we try in relative path;
49
70
  // console.log('context.resourcePath', context.resourcePath, context);
50
71
  // let contextResourcePath = context.resourcePath;
51
72
  const filePaths = context.resourcePath.split(_path.default.sep);
@@ -53,7 +74,8 @@ var _default = (unique = true, {
53
74
  const [fileNameWithoutExt] = fileName.split('.');
54
75
  const cleanFileName = fileNameWithoutExt.replace(/-/g, '_').toLowerCase();
55
76
 
56
- const relativePath = _path.default.relative(context.rootContext, context.resourcePath);
77
+ const relativePath = _path.default.relative(context.rootContext, context.resourcePath); // console.log('customClassNamePrefix', customClassNamePrefix);
78
+
57
79
  /*
58
80
  input :
59
81
  context.resourcePath : 'D:/MyWork/..../desk_client_app/supportapp/src/components/Avatar/Avatar.module.css,
@@ -86,7 +108,18 @@ var _default = (unique = true, {
86
108
  if (unique) {
87
109
  const h = (0, _getHash.default)(`${relativePath}-${localName}`, 10);
88
110
  return `${classNamePrefix}${h}`;
89
- } //css file has casesensitive selector issue so can't toLowerCase
111
+ }
112
+
113
+ const patternClass = patternBasedClass({
114
+ customClassNamePrefix,
115
+ context,
116
+ relativePath,
117
+ localName
118
+ });
119
+
120
+ if (patternClass) {
121
+ return patternClass;
122
+ } //css file has case sensitive selector issue so can't toLowerCase
90
123
  //let local = localName.toLowerCase()
91
124
 
92
125