@zohodesk/react-cli 1.0.1 → 1.0.2-exp.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (137) hide show
  1. package/.eslintignore +7 -7
  2. package/.eslintrc.js +180 -180
  3. package/.prettierrc +6 -6
  4. package/Changelog.md +1019 -1019
  5. package/README.md +1165 -1160
  6. package/bin/cli.js +483 -483
  7. package/docs/CustomChunks.md +26 -26
  8. package/docs/DevServerPort.md +39 -39
  9. package/docs/DevStart.md +18 -18
  10. package/docs/HoverActive.md +12 -12
  11. package/docs/InstallNode.md +28 -28
  12. package/docs/SelectorWeight.md +8 -8
  13. package/docs/TODOS.md +10 -10
  14. package/docs/ValueReplacer.md +60 -60
  15. package/docs/VariableConversion.md +729 -729
  16. package/docs/warnings_while_install.txt +35 -35
  17. package/files/eslintrc.js +62 -62
  18. package/files/prettierrc.js +3 -3
  19. package/lib/configs/webpack.css.umd.config.js +4 -4
  20. package/lib/configs/webpack.dev.config.js +6 -0
  21. package/lib/configs/webpack.docs.config.js +4 -0
  22. package/lib/configs/webpack.impact.config.js +4 -0
  23. package/lib/configs/webpack.prod.config.js +6 -0
  24. package/lib/loaderUtils/configsAssetsLoaders.js +33 -33
  25. package/lib/loaderUtils/getCSSLoaders.js +79 -50
  26. package/lib/loaderUtils/tests/windowsModification.test.js +10 -0
  27. package/lib/loaderUtils/windowsModification.js +6 -1
  28. package/lib/loaders/composeLoader.js +175 -0
  29. package/lib/loaders/workerLoader.js +9 -9
  30. package/lib/pluginUtils/getDevPlugins.js +18 -7
  31. package/lib/pluginUtils/getProdPlugins.js +6 -6
  32. package/lib/pluginUtils/getUMDCSSPlugins.js +1 -1
  33. package/lib/pluginUtils/getUMDComponentPlugins.js +1 -1
  34. package/lib/plugins/EFCPlugin.md +6 -6
  35. package/lib/plugins/I18NInjectIntoIndexPlugin.js +4 -4
  36. package/lib/plugins/I18nSplitPlugin/I18nDownlodLogic.js +38 -38
  37. package/lib/plugins/I18nSplitPlugin/I18nFilesEmitter.js +30 -30
  38. package/lib/plugins/I18nSplitPlugin/I18nKeysIdentifer.js +8 -8
  39. package/lib/plugins/I18nSplitPlugin/I18nSplit.md +95 -95
  40. package/lib/plugins/I18nSplitPlugin/README.md +25 -25
  41. package/lib/plugins/I18nSplitPlugin/index.js +57 -57
  42. package/lib/plugins/{UglifyCSSPlugin.js → MinifyPlugin.js} +3 -3
  43. package/lib/plugins/ResourceHintsPlugin.js +17 -17
  44. package/lib/plugins/RtlSplitPlugin/RtlCssPlugin.js +6 -6
  45. package/lib/plugins/RtlSplitPlugin/RtrSplit.md +30 -30
  46. package/lib/plugins/SelectorPlugin.js +56 -45
  47. package/lib/plugins/ServiceWorkerPlugin.js +9 -9
  48. package/lib/plugins/TPHashMappingPlugin.js +4 -4
  49. package/lib/plugins/VariableConversionCollector.js +93 -84
  50. package/lib/plugins/index.js +15 -7
  51. package/lib/plugins/utils/classHandling.js +20 -0
  52. package/lib/plugins/utils/fileHandling.js +92 -0
  53. package/lib/plugins/utils/tests/fileHandling.test.js +30 -0
  54. package/lib/postcss-plugins/EmptyPlugin.js +8 -0
  55. package/lib/postcss-plugins/ExcludePlugin.js +1 -1
  56. package/lib/postcss-plugins/RTLSplitPlugin.js +10 -10
  57. package/lib/postcss-plugins/SelectorReplace.js +80 -0
  58. package/lib/postcss-plugins/ValueReplacer.js +2 -13
  59. package/lib/postcss-plugins/__test__/selectorReplace.test.js +28 -0
  60. package/lib/postcss-plugins/__test__/test1Input.css +38 -38
  61. package/lib/postcss-plugins/__test__/test1Output.css +38 -38
  62. package/lib/postcss-plugins/hoverActivePlugin.js +3 -3
  63. package/lib/postcss-plugins/variableModificationPlugin/index.js +1 -19
  64. package/lib/postcss-plugins/variableModifier.js +1 -1
  65. package/lib/schemas/index.js +34 -3
  66. package/lib/servers/server.js +2 -2
  67. package/lib/sh/pre-commit.sh +34 -34
  68. package/lib/sh/reportPublish.sh +45 -45
  69. package/lib/utils/buildstats.html +148 -148
  70. package/lib/utils/cssClassNameGenerate.js +35 -7
  71. package/lib/utils/resultSchema.json +73 -73
  72. package/npm8.md +9 -9
  73. package/package.json +122 -121
  74. package/postpublish.js +8 -8
  75. package/templates/app/.eslintrc.js +140 -140
  76. package/templates/app/README.md +12 -12
  77. package/templates/app/app/index.html +24 -24
  78. package/templates/app/app/properties/ApplicationResources_en_US.properties +1 -1
  79. package/templates/app/app/properties/i18nkeys.json +3 -3
  80. package/templates/app/docs/all.html +69 -69
  81. package/templates/app/mockapi/index.js +18 -18
  82. package/templates/app/package.json +37 -37
  83. package/templates/app/src/actions/SampleActions/index.js +37 -37
  84. package/templates/app/src/actions/index.js +65 -65
  85. package/templates/app/src/appUrls.js +19 -19
  86. package/templates/app/src/components/Alert/Alert.js +134 -134
  87. package/templates/app/src/components/Alert/Alert.module.css +79 -79
  88. package/templates/app/src/components/FreezeLayer/FreezeLayer.css +37 -37
  89. package/templates/app/src/components/FreezeLayer/FreezeLayer.js +84 -84
  90. package/templates/app/src/components/Sample/Sample.module.css +11 -11
  91. package/templates/app/src/components/Sample/SampleList.js +61 -61
  92. package/templates/app/src/components/Slider/Slider.css +41 -41
  93. package/templates/app/src/components/Slider/Slider.js +55 -55
  94. package/templates/app/src/containers/AlertContainer/index.js +15 -15
  95. package/templates/app/src/containers/AppContainer/index.js +96 -96
  96. package/templates/app/src/containers/AppContainer/index.module.css +27 -27
  97. package/templates/app/src/containers/CustomMatch/index.js +65 -65
  98. package/templates/app/src/containers/DevTools/index.js +10 -10
  99. package/templates/app/src/containers/Header/index.js +67 -67
  100. package/templates/app/src/containers/Header/index.module.css +43 -43
  101. package/templates/app/src/containers/Redirect/index.js +63 -63
  102. package/templates/app/src/containers/Redirector/index.js +47 -47
  103. package/templates/app/src/containers/SampleListContainer/ListContainer.js +42 -42
  104. package/templates/app/src/containers/SampleListContainer/ListContainer.module.css +3 -3
  105. package/templates/app/src/historyChange.js +5 -5
  106. package/templates/app/src/index.html +10 -10
  107. package/templates/app/src/index.js +24 -24
  108. package/templates/app/src/middleware/PromiseMiddleware.js +59 -59
  109. package/templates/app/src/reducers/alertData.js +11 -11
  110. package/templates/app/src/reducers/index.js +6 -6
  111. package/templates/app/src/reducers/samples.js +19 -19
  112. package/templates/app/src/store/configureStore.dev.js +51 -51
  113. package/templates/app/src/store/configureStore.js +5 -5
  114. package/templates/app/src/store/configureStore.prod.js +26 -26
  115. package/templates/app/src/util/Common.js +5 -5
  116. package/templates/app/src/util/RequestAPI.js +132 -132
  117. package/templates/docs/all.html +249 -249
  118. package/templates/docs/component.html +178 -178
  119. package/templates/docs/components.html +221 -221
  120. package/templates/docs/css/b.min.css +6 -6
  121. package/templates/docs/css/component.css +42 -42
  122. package/templates/docs/css/componentTest.css +6 -6
  123. package/templates/docs/css/hopscotch.css +585 -585
  124. package/templates/docs/css/style.css +1022 -1022
  125. package/templates/docs/impactReportTemplate.html +154 -154
  126. package/templates/docs/index.html +1501 -1501
  127. package/templates/docs/js/active-line.js +72 -72
  128. package/templates/docs/js/b.min.js +7 -7
  129. package/templates/docs/js/codemirror.js +9680 -9680
  130. package/templates/docs/js/designTokens.js +334 -334
  131. package/templates/docs/js/j.min.js +4 -4
  132. package/templates/docs/js/javascript.js +874 -874
  133. package/templates/docs/js/matchbrackets.js +145 -145
  134. package/.vscode/settings.json +0 -11
  135. package/lib/plugins/composeCommonPlugin.js +0 -30
  136. package/result.json +0 -1
  137. package/unittest/index.html +0 -37
@@ -9,32 +9,24 @@ var _postcss = _interopRequireDefault(require("postcss"));
9
9
 
10
10
  var _fs = _interopRequireDefault(require("fs"));
11
11
 
12
+ var _classHandling = require("./utils/classHandling");
13
+
14
+ var _fileHandling = require("./utils/fileHandling");
15
+
12
16
  var _windowsModification = require("../loaderUtils/windowsModification");
13
17
 
14
18
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
15
19
 
16
- function checkFilename(filename, data) {
17
- let keyMatch = undefined;
18
- Object.keys(data).forEach(key => {
19
- if (filename.includes(key)) {
20
- keyMatch = key;
21
- }
22
- });
23
- return keyMatch;
24
- }
25
-
26
- function rootConvertor(rootOriginal, defaultSelector, data, filename, excludeStrings) {
20
+ function selectorWeightPrefixAdder(rootOriginal, selector, excludeStrings) {
27
21
  rootOriginal.walkRules((rule, index) => {
28
22
  const prevNode = rootOriginal.nodes[index - 1];
29
23
 
30
- if (index !== 0 && prevNode.type && prevNode.type === 'comment' && prevNode.text.toLowerCase() === 'updateselector:ignore') {
24
+ if ((0, _classHandling.hasPrevNodeIgnore)(index, prevNode, 'updateselector:ignore')) {
31
25
  return;
32
26
  }
33
27
 
34
- if (rule.parent && rule.parent.type === 'atrule') {
35
- if (rule.parent.name !== 'media') {
36
- return;
37
- }
28
+ if (!(0, _classHandling.isInsideMediaQuery)(rule)) {
29
+ return;
38
30
  }
39
31
 
40
32
  const selectorArr = rule.selector.split(',');
@@ -46,40 +38,26 @@ function rootConvertor(rootOriginal, defaultSelector, data, filename, excludeStr
46
38
  if (singleSelectorStr.includes(']')) {
47
39
  if (singleSelectorStr.slice(singleSelectorStr.lastIndexOf(']') + 2).trim() === '') {
48
40
  return;
49
- } // console.log(
50
- // rule.slice(rule.lastIndexOf(']') + 2).trim(),
51
- // rule.slice(rule.lastIndexOf(']') + 2).trim() !== ''
52
- // );
53
-
54
-
55
- selectorArr[index] = `${singleSelectorStr.slice(0, singleSelectorStr.lastIndexOf(']') + 1).trim()} ${defaultSelector}${singleSelectorStr.slice(singleSelectorStr.lastIndexOf(']') + 2).trim()}`; // console.log(ruleArr[index]);
41
+ }
56
42
 
43
+ selectorArr[index] = `${singleSelectorStr.slice(0, singleSelectorStr.lastIndexOf(']') + 1).trim()} ${selector}${singleSelectorStr.slice(singleSelectorStr.lastIndexOf(']') + 2).trim()}`;
57
44
  return;
58
45
  }
59
46
 
60
- const keyMatch = checkFilename(filename, data);
61
- selectorArr[index] = data[keyMatch] ? `${data[keyMatch].defaultSelector}${singleSelectorStr}` : `${defaultSelector}${singleSelectorStr}`;
47
+ selectorArr[index] = `${selector}${singleSelectorStr}`;
62
48
  });
63
- rule.selector = selectorArr.join(',\n'); // console.log(`${rule.selector} converted`);
49
+ rule.selector = selectorArr.join(',\n');
64
50
  });
65
51
  return rootOriginal;
66
52
  }
67
53
 
68
- function ignoreFile(excludeArr, filename) {
69
- let ignore = false;
70
- excludeArr.forEach(exclStr => {
71
- if (filename.includes(exclStr)) {
72
- ignore = true;
73
- }
74
- });
75
- return ignore;
76
- }
77
-
78
54
  class SelectorPlugin {
79
55
  constructor(options = {}) {
80
56
  this.optimize = options.optimize;
81
57
  this.selectorWeightConfig = options.selectorWeightConfig;
82
58
  this.exclude = options.exclude;
59
+ this.patterns = options.patterns;
60
+ this.rootDir = options.patternsRootDir;
83
61
  }
84
62
 
85
63
  apply(compiler) {
@@ -99,16 +77,49 @@ class SelectorPlugin {
99
77
  mods.forEach(module => {
100
78
  const rootOriginal = _postcss.default.parse(module.content);
101
79
 
102
- const filename = module.issuer.resource; // if (!filename.includes('node_modules')) {
103
-
104
- if (ignoreFile(this.exclude, filename)) {
80
+ const filename = module.issuer.resource;
81
+ /*
82
+ input :
83
+ filename : 'D:/MyWork/..../desk_client_app/supportapp/src/components/Avatar/Avatar.module.css,
84
+
85
+ patterns.cssVariableReplacement:
86
+ // include src folder, include deskapp folder, exclude node modules
87
+ "selectorWeight": [
88
+ "src",
89
+ "deskapp",
90
+ "!node_modules"
91
+ ]
92
+ rootDir : patternsRootDir : 'supportapp'
93
+
94
+ output :
95
+ true or false
96
+ */
97
+
98
+ if (!(0, _fileHandling.isFileNameMatchingPluginPattern)({
99
+ filename,
100
+ filterArr: this.patterns.selectorWeight,
101
+ rootDir: this.rootDir
102
+ })) {
105
103
  return;
106
- } // console.log(filename);
107
-
108
-
109
- module.content = //new RawSource(
110
- rootConvertor(rootOriginal, defaultSelector, data, filename, excludeStrings).toString(); // );
111
- // }
104
+ }
105
+ /*
106
+
107
+ filename : Deskapp.module.css ?
108
+ data :
109
+ {
110
+ "DeskApp.module.css": {"defaultSelector" : ".desk_app_ui "}
111
+ }
112
+ selectorWeightConfig :
113
+ defaultSelector : .zoho_desk_ui
114
+
115
+ case filename = 'DeskApp.module.css' ?
116
+ data[filename].defaultSelector = '.desk_app_ui'
117
+ case filename is different ?
118
+ defaultSelector = '.zoho_desk_ui'
119
+ */
120
+
121
+
122
+ module.content = selectorWeightPrefixAdder(rootOriginal, data[filename] ? data[filename].defaultSelector : defaultSelector, excludeStrings).toString();
112
123
  });
113
124
  });
114
125
  });
@@ -51,11 +51,11 @@ class ServiceWorkerPlugin {
51
51
  if (err) {
52
52
  throw new Error(err);
53
53
  } else {
54
- /* const extractedChunks = compilation.chunks.filter(chunk => {
55
- if ('canBeInitial' in chunk) {
56
- return chunk.canBeInitial();
57
- }
58
- return chunk.isInitial();
54
+ /* const extractedChunks = compilation.chunks.filter(chunk => {
55
+ if ('canBeInitial' in chunk) {
56
+ return chunk.canBeInitial();
57
+ }
58
+ return chunk.isInitial();
59
59
  }); */
60
60
  // let [js, css, , , i18nPublicPath] = this.publicPaths;
61
61
  // let initialChunkUrls = [];
@@ -64,10 +64,10 @@ class ServiceWorkerPlugin {
64
64
  let entrypoint = compilation.entrypoints.get('main');
65
65
  let initialChunkUrls = entrypoint.getFiles();
66
66
  const cssDirTemplate = '@dir@';
67
- /**
68
- * NOTE:
69
- * if chunkSplitEnable is false means,
70
- * serviceWorker will get i18n files path for html
67
+ /**
68
+ * NOTE:
69
+ * if chunkSplitEnable is false means,
70
+ * serviceWorker will get i18n files path for html
71
71
  */
72
72
 
73
73
  let initalI18nAssets = chunkSplitEnable ? entrypoint.chunks.filter(chunk => _I18nKeysIdentifer.default.isChunkHasI18n(chunk)).map(chunk => (0, _getI18nFileUrlPathTemplate.getI18nFileUrlPathTemplate)(compilation, chunk, this.i18nFileNameTemplate, '@locale@')) : [];
@@ -15,10 +15,10 @@ var _crypto = _interopRequireDefault(require("crypto"));
15
15
 
16
16
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
17
17
 
18
- /**
19
- * Plugin that generates hash for the provided list of third party files
20
- * Map the provided key with the file hash and add it to the list of exisiting global constants.
21
- * Plugin in turn uses the defineplugin to generate global constants.
18
+ /**
19
+ * Plugin that generates hash for the provided list of third party files
20
+ * Map the provided key with the file hash and add it to the list of exisiting global constants.
21
+ * Plugin in turn uses the defineplugin to generate global constants.
22
22
  */
23
23
  class TPHashMappingPlugin {
24
24
  constructor(options) {
@@ -9,6 +9,8 @@ var _postcss = _interopRequireDefault(require("postcss"));
9
9
 
10
10
  var _ErrorHandler = require("../postcss-plugins/variableModificationPlugin/ErrorHandler");
11
11
 
12
+ var _fileHandling = require("./utils/fileHandling");
13
+
12
14
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
13
15
 
14
16
  // import { RawSource } from 'webpack-sources';
@@ -26,15 +28,15 @@ const {
26
28
  const supportedProps = ['font-size', 'margin', 'margin-top', 'margin-bottom', 'margin-left', 'margin-right', 'padding', 'padding-top', 'padding-bottom', 'padding-left', 'padding-right', '^top', '^right', '^bottom', '^left', '^width', 'min-width', 'max-width', '^height', 'min-height', 'max-height', 'text-indent', 'clip', 'flex-basis', 'row-gap', 'gap', 'column-gap', 'flex']; // const avoidProps = [];
27
29
  // -- is issue IO --
28
30
 
29
- /*
30
- issues eg :
31
- issues = ['--zd_size', '--zd_font_size', '--size', '--size_'];
32
- input :
33
- --zd_size
34
- output :
35
- true
36
- comment :
37
- do not execute when --zd_size comes as prop
31
+ /*
32
+ issues eg :
33
+ issues = ['--zd_size', '--zd_font_size', '--size', '--size_'];
34
+ input :
35
+ --zd_size
36
+ output :
37
+ true
38
+ comment :
39
+ do not execute when --zd_size comes as prop
38
40
  */
39
41
 
40
42
  function isIgnoreValuePresent(ignoreVals, prop) {
@@ -47,14 +49,14 @@ function isIgnoreValuePresent(ignoreVals, prop) {
47
49
  return present;
48
50
  } // -- to convert the hyphen values to values --
49
51
 
50
- /*
51
- input :
52
- var(--zdt_uploadlist_default_width)
53
- output :
54
- --zdt_uploadlist_default_width
55
-
56
- comment :
57
- to make the variable object using the output as key and decl.prop such as font-size as value
52
+ /*
53
+ input :
54
+ var(--zdt_uploadlist_default_width)
55
+ output :
56
+ --zdt_uploadlist_default_width
57
+
58
+ comment :
59
+ to make the variable object using the output as key and decl.prop such as font-size as value
58
60
  */
59
61
 
60
62
 
@@ -62,7 +64,7 @@ function extractVariableName(val) {
62
64
  return val.replace(/calc\((.+)\)/gi, '$1').replace(/var\((.+)\)/gi, '$1').replace('-1', '').replace('*', '').replace('\n', '').trim();
63
65
  }
64
66
 
65
- function rootConvertor(rootOriginal, variables, settingsObject) {
67
+ function variableConvertor(rootOriginal, variables, settingsObject) {
66
68
  rootOriginal.walkRules(rule => {
67
69
  rule.nodes.forEach((decl, index) => {
68
70
  const prevNode = rule.nodes[index - 1];
@@ -118,10 +120,12 @@ class VariableConversionCollector {
118
120
  constructor(options = {}) {
119
121
  this.optimize = options.optimize;
120
122
  this.filename = options.cssVariableReplacementConfig;
121
- this.fileHandler();
123
+ this.patterns = options.patterns;
124
+ this.rootDir = options.patternsRootDir;
125
+ this.initializeFiles();
122
126
  }
123
127
 
124
- fileHandler() {
128
+ initializeFiles() {
125
129
  createFolderIfNonExistant('./.cli/logs/');
126
130
  createFolderIfNonExistant('./.cli/config/variables/');
127
131
  createFolderIfNonExistant('./.cli/config/selectorWeight/');
@@ -131,7 +135,8 @@ class VariableConversionCollector {
131
135
 
132
136
  apply(compiler) {
133
137
  const variables = {};
134
- const unassigned = {};
138
+ const unassigned = {}; // console.log(windowsModification([this.filename])[0]);
139
+
135
140
  const rawdata = fs.readFileSync(this.filename);
136
141
  const data = JSON.parse(rawdata);
137
142
  const {
@@ -154,13 +159,13 @@ class VariableConversionCollector {
154
159
  }
155
160
  };
156
161
  }
157
- /*
158
- purpose of tap : to create a variable object such as:
159
- {
160
- --zdt_uploadlist_default_width : width,
161
- --zdt_uploadlist_default_height : height,
162
- }
163
- which will help in the conversion further
162
+ /*
163
+ purpose of tap : to create a variable object such as:
164
+ {
165
+ --zdt_uploadlist_default_width : width,
166
+ --zdt_uploadlist_default_height : height,
167
+ }
168
+ which will help in the conversion further
164
169
  */
165
170
 
166
171
 
@@ -216,19 +221,19 @@ class VariableConversionCollector {
216
221
  });
217
222
  });
218
223
  });
219
- /*
220
- current value example:
221
- {
222
- --zdt_uploadlist_default_width : --zd_upload_width,
223
- --zd_upload_width : width
224
- }
225
- expected value :
226
- {
227
- --zdt_uploadlist_default_width : width,
228
- --zd_upload_width : width
229
- }
230
-
231
- conversion is done in the while loop below
224
+ /*
225
+ current value example:
226
+ {
227
+ --zdt_uploadlist_default_width : --zd_upload_width,
228
+ --zd_upload_width : width
229
+ }
230
+ expected value :
231
+ {
232
+ --zdt_uploadlist_default_width : width,
233
+ --zd_upload_width : width
234
+ }
235
+
236
+ conversion is done in the while loop below
232
237
  */
233
238
 
234
239
  Object.keys(variables).forEach(key => {
@@ -238,36 +243,62 @@ class VariableConversionCollector {
238
243
  });
239
244
  }
240
245
  });
241
- }); // -- conversion for the root using rootConvertor --
242
-
243
- /*
244
- input :
245
- .a{
246
- padding : 20px
247
- }
248
- output :
249
- // on settingObject file :
250
- { padding : { replacements : { px : 'zd_size$$' }}}
251
- .a{
252
- padding : zd_size20;
253
- }
246
+ }); // -- conversion for the root using variableConvertor --
247
+
248
+ /*
249
+ input :
250
+ .a{
251
+ padding : 20px
252
+ }
253
+ output :
254
+ // on settingObject file :
255
+ { padding : { replacements : { px : 'zd_size$$' }}}
256
+ .a{
257
+ padding : zd_size20;
258
+ }
254
259
  */
255
260
 
256
261
  compilation.hooks.optimizeModules.tap('VariableConversionCollector', modules => {
257
262
  const mods = modules.filter(x => x.type.includes('css'));
258
263
  mods.forEach(module => {
264
+ const filename = module.issuer.resource;
265
+ /*
266
+ input :
267
+ filename : 'D:/MyWork/..../desk_client_app/supportapp/src/components/Avatar/Avatar.module.css,
268
+
269
+ patterns.cssVariableReplacement:
270
+ // include src folder, include deskapp folder, exclude node modules
271
+ "cssVariableReplacement": [
272
+ "src",
273
+ "deskapp",
274
+ "!node_modules"
275
+ ]
276
+ rootDir : patternsRootDir : 'supportapp'
277
+
278
+ output :
279
+ true or false
280
+ */
281
+
282
+ if (!(0, _fileHandling.isFileNameMatchingPluginPattern)({
283
+ filename,
284
+ filterArr: this.patterns.cssVariableReplacement,
285
+ rootDir: this.rootDir
286
+ })) {
287
+ return;
288
+ }
289
+
259
290
  const rootOriginal = _postcss.default.parse(module.content);
260
291
 
261
- module.content = rootConvertor(rootOriginal, variables, settingsObject).toString();
292
+ module.content = variableConvertor(rootOriginal, variables, settingsObject).toString();
262
293
  });
263
294
  });
264
295
  });
265
- /*
266
- purpose of tap : to display the errors encountered so far
267
- input :
268
- all css files
269
- output :
270
- all errors that are present in the errTable arr
296
+ /*
297
+ purpose of tap : to display the errors encountered so far
298
+ input :
299
+ all css files
300
+ output :
301
+ all errors that are present in the errTable arr
271
302
  */
272
303
 
273
304
  compiler.hooks.afterEmit.tap('error-display', () => {
@@ -292,29 +323,7 @@ class VariableConversionCollector {
292
323
  if (a.type < b.type) {
293
324
  return -1;
294
325
  }
295
- }); // variable constructed now to be written in a json file
296
- // const newVars = Object.keys(variables)
297
- // //Filter Object with key contanis "NAME"
298
- // .filter(key => variables[key].includes('--'))
299
- // .reduce(
300
- // (obj, key) =>
301
- // Object.assign(obj, {
302
- // [key]: variables[key]
303
- // }),
304
- // {}
305
- // );
306
- // console.log('new variables: ', newVars);
307
- // try {
308
- // fs.writeFileSync('./variableMapping.json', JSON.stringify(variables));
309
- // } catch (err) {
310
- // console.log(err);
311
- // }
312
- // fs.writeFile('./variableMapping.json', JSON.stringify(variables), err => {
313
- // if (err) {
314
- // throw err;
315
- // }
316
- // console.log('variable mapping file generated.');
317
- // });
326
+ });
318
327
 
319
328
  if (errorConsoleStatus) {
320
329
  const errorHandler = new _ErrorHandler.ErrorHandler();
@@ -15,6 +15,12 @@ Object.defineProperty(exports, "CleanUpStatsPlugin", {
15
15
  return _CleanupStatsPlugin.default;
16
16
  }
17
17
  });
18
+ Object.defineProperty(exports, "ComposeMinificationPlugin", {
19
+ enumerable: true,
20
+ get: function () {
21
+ return _ComposeMinification.default;
22
+ }
23
+ });
18
24
  Object.defineProperty(exports, "EFCPlugin", {
19
25
  enumerable: true,
20
26
  get: function () {
@@ -33,6 +39,12 @@ Object.defineProperty(exports, "ManifestPlugin", {
33
39
  return _ManifestPlugin.default;
34
40
  }
35
41
  });
42
+ Object.defineProperty(exports, "MinifyPlugin", {
43
+ enumerable: true,
44
+ get: function () {
45
+ return _MinifyPlugin.default;
46
+ }
47
+ });
36
48
  Object.defineProperty(exports, "ModuleStatsPlugin", {
37
49
  enumerable: true,
38
50
  get: function () {
@@ -99,12 +111,6 @@ Object.defineProperty(exports, "TPHashMappingPlugin", {
99
111
  return _TPHashMappingPlugin.default;
100
112
  }
101
113
  });
102
- Object.defineProperty(exports, "UglifyCSSPlugin", {
103
- enumerable: true,
104
- get: function () {
105
- return _UglifyCSSPlugin.default;
106
- }
107
- });
108
114
  Object.defineProperty(exports, "UnusedFilesFindPlugin", {
109
115
  enumerable: true,
110
116
  get: function () {
@@ -126,10 +132,12 @@ var _OptimizeJSPlugin = _interopRequireDefault(require("./OptimizeJSPlugin"));
126
132
 
127
133
  var _ResourceHintsPlugin = _interopRequireDefault(require("./ResourceHintsPlugin"));
128
134
 
129
- var _UglifyCSSPlugin = _interopRequireDefault(require("./UglifyCSSPlugin"));
135
+ var _MinifyPlugin = _interopRequireDefault(require("./MinifyPlugin"));
130
136
 
131
137
  var _ManifestPlugin = _interopRequireDefault(require("./ManifestPlugin"));
132
138
 
139
+ var _ComposeMinification = _interopRequireDefault(require("./ComposeMinification"));
140
+
133
141
  var _CleanupStatsPlugin = _interopRequireDefault(require("./CleanupStatsPlugin"));
134
142
 
135
143
  var _EFCPlugin = _interopRequireDefault(require("./EFCPlugin"));
@@ -0,0 +1,20 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.hasPrevNodeIgnore = hasPrevNodeIgnore;
7
+ exports.isAtRule = isAtRule;
8
+ exports.isInsideMediaQuery = isInsideMediaQuery;
9
+
10
+ function hasPrevNodeIgnore(index, prevNode, ignoreComment) {
11
+ return index !== 0 && prevNode && prevNode.type && prevNode.type === 'comment' && prevNode.text.toLowerCase() === ignoreComment;
12
+ }
13
+
14
+ function isAtRule(rule) {
15
+ return rule.parent && rule.parent.type === 'atrule';
16
+ }
17
+
18
+ function isInsideMediaQuery(rule) {
19
+ return isAtRule(rule) && rule.parent && rule.parent.name === 'media' ? true : false;
20
+ }
@@ -0,0 +1,92 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.isFileNameMatchingPattern = isFileNameMatchingPattern;
7
+ exports.isFileNameMatchingPluginPattern = isFileNameMatchingPluginPattern;
8
+
9
+ var _windowsModification = require("../../loaderUtils/windowsModification");
10
+
11
+ var _ignore = _interopRequireDefault(require("ignore"));
12
+
13
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
14
+
15
+ let aliasNames = {
16
+ valueReplacer: 'postcss-value-replacer',
17
+ selectorReplace: 'postcss-selector-replace-new',
18
+ hasRTL: 'postcss-rtl',
19
+ combinerMediaQuery: 'postcss-combine-media-query',
20
+ hoverActive: 'postcss-mobile-hover',
21
+ cssVariableReplacement: 'postcss-variable-report',
22
+ composeMinification: 'postcss-compose-plugin'
23
+ };
24
+ /*
25
+
26
+ unique scenario
27
+
28
+ */
29
+ // export function filterFileCssUniqueness(filename, filterObj) {
30
+ // let rootDir = 'supportapp';
31
+ // let include = false;
32
+ // const regex = `^(.+?)${rootDir}?\\\\`;
33
+ // const newFilename = windowsModificationFile(filename).replace(
34
+ // new RegExp(regex, 'gi'),
35
+ // ''
36
+ // );
37
+ // Object.keys(filterObj).forEach(key => {
38
+ // const ig = ignore().add(filterObj[key]);
39
+ // if (ig.ignores(newFilename)) {
40
+ // include = true;
41
+ // }
42
+ // });
43
+ // return include;
44
+ // }
45
+
46
+ function isFileNameMatchingPattern({
47
+ filename,
48
+ filterObject,
49
+ plugins,
50
+ rootDir
51
+ }) {
52
+ const finalPlugins = []; // console.log(rootDir);
53
+
54
+ const regex = `^(.+?)${rootDir}?\\\\`;
55
+ const newFilename = (0, _windowsModification.windowsModificationFile)(filename).replace(new RegExp(regex, 'gi'), '');
56
+ Object.keys(filterObject).forEach(key => {
57
+ plugins.forEach(x => {
58
+ // console.log(key, x.postcssPlugin);
59
+ if (aliasNames[key] === x.postcssPlugin) {
60
+ const ig = (0, _ignore.default)().add(filterObject[key]);
61
+
62
+ if (ig.ignores(newFilename)) {
63
+ // console.log(newFilename);
64
+ finalPlugins.push(x);
65
+ }
66
+ }
67
+ });
68
+ }); // console.log(filename);
69
+ // console.log(finalPlugins);
70
+ // console.log('----------------------------------------------------------------------')
71
+
72
+ return finalPlugins; // console.log(filename, filterObject);
73
+ }
74
+
75
+ function isFileNameMatchingPluginPattern({
76
+ filename,
77
+ filterArr,
78
+ rootDir
79
+ }) {
80
+ let include = true; // console.log(rootDir);
81
+
82
+ const regex = `^(.+?)${rootDir}?\\\\`; // console.log(plugin);
83
+
84
+ const newFilename = (0, _windowsModification.windowsModificationFile)(filename).replace(new RegExp(regex, 'gi'), '');
85
+ const ig = (0, _ignore.default)().add(filterArr);
86
+
87
+ if (!ig.ignores(newFilename)) {
88
+ include = false;
89
+ }
90
+
91
+ return include;
92
+ }
@@ -0,0 +1,30 @@
1
+ "use strict";
2
+
3
+ const ignore = require('ignore');
4
+
5
+ const ignoreArr1 = ['src', '!src\\components', 'src\\Accessibility'];
6
+ const ignoreArr2 = ['src\\', '!node_modules\\'];
7
+ const ignoreArr3 = ['*'];
8
+
9
+ const {
10
+ windowsModificationFile
11
+ } = require('../../../../lib/loaderUtils/windowsModification');
12
+
13
+ const files = ['D:\\MyWork\\React Build\\desk_client_app\\jsapps\\supportapp\\src\\components\\Accessibility\\Accessibility.module.css', 'D:\\MyWork\\React Build\\desk_client_app\\jsapps\\supportapp\\src\\components\\Avatar\\Avatar.module.css', 'D:/MyWork/React Build/desk_client_app/jsapps/supportapp/src/components/Accessibility/Accessibility.module.css', 'D:/MyWork/React Build/desk_client_app/jsapps/supportapp/src/components/Accessibility/AccessibilityNavigation.module.css', 'desk_client_app\\jsapps\\supportapp\\src\\components\\Test.module.css', 'desk_client_app\\jsapps\\supportapp\\src\\components\\Accessibility\\Accessibility.module.css', 'desk_client_app/jsapps/supportapp/src/components/Accessibility/Accessibility.module.css', 'src\\components\\Accessibility\\Accessibility.module.css', 'src/components/Accessibility/Accessibility.module.css', 'Accessibility.module.css', ''];
14
+ const ignore1 = ignore().add(ignoreArr1);
15
+ const ignore2 = ignore().add(ignoreArr2);
16
+ const ignore3 = ignore().add(ignoreArr3);
17
+ files.forEach(file => {
18
+ // console.log(file);
19
+ const rootDir = 'supportapp';
20
+ const regex = `^(.+?)${rootDir}?\\\\`;
21
+ const newFilename = windowsModificationFile(file).replace(new RegExp(regex, 'gi'), '');
22
+ console.log(newFilename);
23
+
24
+ if (newFilename.trim() !== '') {
25
+ console.log(ignore1.ignores(newFilename));
26
+ console.log(ignore2.ignores(newFilename));
27
+ console.log(ignore3.ignores(newFilename));
28
+ console.log('--------------------------------------------------------------------');
29
+ }
30
+ });
@@ -0,0 +1,8 @@
1
+ "use strict";
2
+
3
+ var _postcss = _interopRequireDefault(require("postcss"));
4
+
5
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
6
+
7
+ module.exports = _postcss.default.plugin('postcss-empty', () => (root, result) => {// console.log(root.source.input.from, result);
8
+ });
@@ -10,7 +10,7 @@ module.exports = _postcss.default.plugin('postcss-exclude-files', opts => {
10
10
  } = opts;
11
11
  return (root, result) => {
12
12
  const inputFile = root.source.input.file;
13
- let isIgnoredFile = opts.ignore.some(file => inputFile.indexOf(file) !== -1);
13
+ const isIgnoredFile = opts.ignore.some(file => inputFile.indexOf(file) !== -1);
14
14
 
15
15
  if (!isIgnoredFile) {
16
16
  const handler = response => response.messages.forEach(msg => result.messages.push(msg));