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

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (126) 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 +1152 -1161
  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 +6 -6
  13. package/docs/TODOS.md +10 -10
  14. package/docs/ValueReplacer.md +60 -60
  15. package/docs/VariableConversion.md +724 -724
  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/common/getEntries.js +6 -9
  20. package/lib/configs/webpack.css.umd.config.js +4 -4
  21. package/lib/configs/webpack.docs.config.js +14 -26
  22. package/lib/loaderUtils/configsAssetsLoaders.js +33 -33
  23. package/lib/loaders/workerLoader.js +9 -9
  24. package/lib/pluginUtils/configHtmlWebpackPlugins.js +1 -2
  25. package/lib/pluginUtils/getDevPlugins.js +8 -9
  26. package/lib/pluginUtils/getDocsPlugins.js +3 -16
  27. package/lib/pluginUtils/getProdPlugins.js +5 -7
  28. package/lib/plugins/EFCPlugin.md +6 -6
  29. package/lib/plugins/I18NInjectIntoIndexPlugin.js +4 -4
  30. package/lib/plugins/I18nSplitPlugin/I18nDownlodLogic.js +38 -38
  31. package/lib/plugins/I18nSplitPlugin/I18nFilesEmitter.js +30 -30
  32. package/lib/plugins/I18nSplitPlugin/I18nKeysIdentifer.js +8 -8
  33. package/lib/plugins/I18nSplitPlugin/I18nSplit.md +95 -95
  34. package/lib/plugins/I18nSplitPlugin/README.md +25 -25
  35. package/lib/plugins/I18nSplitPlugin/index.js +57 -57
  36. package/lib/plugins/ResourceHintsPlugin.js +17 -17
  37. package/lib/plugins/RtlSplitPlugin/RtlCssPlugin.js +6 -6
  38. package/lib/plugins/RtlSplitPlugin/RtrSplit.md +30 -30
  39. package/lib/plugins/SelectorPlugin.js +71 -25
  40. package/lib/plugins/ServiceWorkerPlugin.js +9 -9
  41. package/lib/plugins/TPHashMappingPlugin.js +4 -4
  42. package/lib/plugins/VariableConversionCollector.js +54 -54
  43. package/lib/plugins/cssoPlugin.js +37 -0
  44. package/lib/plugins/utils/checkPattern.js +57 -0
  45. package/lib/plugins/utils/classHandling.js +28 -0
  46. package/lib/plugins/utils/fileHandling.js +122 -0
  47. package/lib/postcss-plugins/IncludePlugin.js +24 -0
  48. package/lib/postcss-plugins/RTLSplitPlugin.js +10 -10
  49. package/lib/postcss-plugins/__test__/test1Input.css +38 -38
  50. package/lib/postcss-plugins/__test__/test1Output.css +38 -38
  51. package/lib/postcss-plugins/hoverActivePlugin.js +3 -3
  52. package/lib/postcss-plugins/variableModificationPlugin/index.js +23 -1
  53. package/lib/schemas/index.js +0 -8
  54. package/lib/sh/pre-commit.sh +34 -34
  55. package/lib/sh/reportPublish.sh +45 -45
  56. package/lib/utils/buildstats.html +148 -148
  57. package/lib/utils/resultSchema.json +73 -73
  58. package/npm8.md +9 -9
  59. package/package.json +121 -121
  60. package/postpublish.js +8 -8
  61. package/templates/app/.eslintrc.js +140 -140
  62. package/templates/app/README.md +12 -12
  63. package/templates/app/app/index.html +24 -24
  64. package/templates/app/app/properties/ApplicationResources_en_US.properties +1 -1
  65. package/templates/app/app/properties/i18nkeys.json +3 -3
  66. package/templates/app/docs/all.html +69 -69
  67. package/templates/app/mockapi/index.js +18 -18
  68. package/templates/app/package.json +37 -37
  69. package/templates/app/src/actions/SampleActions/index.js +37 -37
  70. package/templates/app/src/actions/index.js +65 -65
  71. package/templates/app/src/appUrls.js +19 -19
  72. package/templates/app/src/components/Alert/Alert.js +134 -134
  73. package/templates/app/src/components/Alert/Alert.module.css +79 -79
  74. package/templates/app/src/components/FreezeLayer/FreezeLayer.css +37 -37
  75. package/templates/app/src/components/FreezeLayer/FreezeLayer.js +84 -84
  76. package/templates/app/src/components/Sample/Sample.module.css +11 -11
  77. package/templates/app/src/components/Sample/SampleList.js +61 -61
  78. package/templates/app/src/components/Slider/Slider.css +41 -41
  79. package/templates/app/src/components/Slider/Slider.js +55 -55
  80. package/templates/app/src/containers/AlertContainer/index.js +15 -15
  81. package/templates/app/src/containers/AppContainer/index.js +96 -96
  82. package/templates/app/src/containers/AppContainer/index.module.css +27 -27
  83. package/templates/app/src/containers/CustomMatch/index.js +65 -65
  84. package/templates/app/src/containers/DevTools/index.js +10 -10
  85. package/templates/app/src/containers/Header/index.js +67 -67
  86. package/templates/app/src/containers/Header/index.module.css +43 -43
  87. package/templates/app/src/containers/Redirect/index.js +63 -63
  88. package/templates/app/src/containers/Redirector/index.js +47 -47
  89. package/templates/app/src/containers/SampleListContainer/ListContainer.js +42 -42
  90. package/templates/app/src/containers/SampleListContainer/ListContainer.module.css +3 -3
  91. package/templates/app/src/historyChange.js +5 -5
  92. package/templates/app/src/index.html +10 -10
  93. package/templates/app/src/index.js +24 -24
  94. package/templates/app/src/middleware/PromiseMiddleware.js +59 -59
  95. package/templates/app/src/reducers/alertData.js +11 -11
  96. package/templates/app/src/reducers/index.js +6 -6
  97. package/templates/app/src/reducers/samples.js +19 -19
  98. package/templates/app/src/store/configureStore.dev.js +51 -51
  99. package/templates/app/src/store/configureStore.js +5 -5
  100. package/templates/app/src/store/configureStore.prod.js +26 -26
  101. package/templates/app/src/util/Common.js +5 -5
  102. package/templates/app/src/util/RequestAPI.js +132 -132
  103. package/templates/docs/all.html +249 -249
  104. package/templates/docs/component.html +178 -178
  105. package/templates/docs/components.html +221 -221
  106. package/templates/docs/css/b.min.css +6 -6
  107. package/templates/docs/css/component.css +42 -42
  108. package/templates/docs/css/componentTest.css +6 -6
  109. package/templates/docs/css/hopscotch.css +585 -585
  110. package/templates/docs/css/style.css +1022 -1022
  111. package/templates/docs/impactReportTemplate.html +154 -154
  112. package/templates/docs/index.html +1501 -1501
  113. package/templates/docs/js/active-line.js +72 -72
  114. package/templates/docs/js/b.min.js +7 -7
  115. package/templates/docs/js/codemirror.js +9680 -9680
  116. package/templates/docs/js/designTokens.js +334 -334
  117. package/templates/docs/js/j.min.js +4 -4
  118. package/templates/docs/js/javascript.js +874 -874
  119. package/templates/docs/js/matchbrackets.js +145 -145
  120. package/lib/configs/webpack.docs1.config.js +0 -122
  121. package/lib/hooks/docsEntry.js +0 -18
  122. package/result.json +0 -1
  123. package/templates/docs/a.html +0 -13
  124. package/templates/docs/docsEntry.js +0 -14
  125. package/templates/docs/docsRoot.js +0 -3
  126. package/unittest/index.html +0 -37
@@ -24,12 +24,12 @@ const isCss = filename => _path.default.extname(filename) === '.css'; // this p
24
24
 
25
25
  class RtlCssPlugin {
26
26
  constructor(options = {}) {
27
- /**
28
- * @typedef {Object} Options
29
- * @property {String} filename [not used]
30
- * @property {String} dirVarName
31
- * @property {Boolean} sourcemap
32
- * @property {Object} config
27
+ /**
28
+ * @typedef {Object} Options
29
+ * @property {String} filename [not used]
30
+ * @property {String} dirVarName
31
+ * @property {Boolean} sourcemap
32
+ * @property {Object} config
33
33
  */
34
34
  this.options = {
35
35
  filename: options.filename || '[name].rtl.css',
@@ -1,30 +1,30 @@
1
- # RTL Split
2
-
3
- we are doing in build time generating rtl related css code by using @zohodesk/postcss-rt npm.
4
- It was automated, That postcss plugin create rtl reacted css and put them into same file, with css selector [dir=rtl] and ltr realted css with [dir=ltr].
5
- Here is problem mostly no one need rtl and ltr related css at the same time in browser,
6
- we are try to split them by [dir] and load which type of css is needed.
7
- For this purpose we created RTL Split Plugin
8
-
9
-
10
- # To Try it out rtl-ltr split
11
- ### how to use this feature?
12
-
13
- to use this feature use have give the below oprtions
14
- `package.json`
15
- ```json
16
- {
17
- /// ...some things
18
- "react-cli": {
19
- // ...some things
20
- "css": {
21
- "enableRTLSplit": true,
22
- "templateLabel": "{{--dir}}",// this is for html template css file path dir template
23
- "disableMiniFiySelector": false,
24
- "dirVarName": "document.dir" // this will be used for download css based on dir
25
- },
26
- // ...some things
27
- }
28
- }
29
- ```
30
-
1
+ # RTL Split
2
+
3
+ we are doing in build time generating rtl related css code by using @zohodesk/postcss-rt npm.
4
+ It was automated, That postcss plugin create rtl reacted css and put them into same file, with css selector [dir=rtl] and ltr realted css with [dir=ltr].
5
+ Here is problem mostly no one need rtl and ltr related css at the same time in browser,
6
+ we are try to split them by [dir] and load which type of css is needed.
7
+ For this purpose we created RTL Split Plugin
8
+
9
+
10
+ # To Try it out rtl-ltr split
11
+ ### how to use this feature?
12
+
13
+ to use this feature use have give the below oprtions
14
+ `package.json`
15
+ ```json
16
+ {
17
+ /// ...some things
18
+ "react-cli": {
19
+ // ...some things
20
+ "css": {
21
+ "enableRTLSplit": true,
22
+ "templateLabel": "{{--dir}}",// this is for html template css file path dir template
23
+ "disableMiniFiySelector": false,
24
+ "dirVarName": "document.dir" // this will be used for download css based on dir
25
+ },
26
+ // ...some things
27
+ }
28
+ }
29
+ ```
30
+
@@ -9,15 +9,21 @@ var _postcss = _interopRequireDefault(require("postcss"));
9
9
 
10
10
  var _fs = _interopRequireDefault(require("fs"));
11
11
 
12
- var _webpackSources = require("webpack-sources");
12
+ var _windowsModification = require("../loaderUtils/windowsModification");
13
13
 
14
14
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
15
15
 
16
- const path = require('path');
17
-
18
- const isCss = filename => path.extname(filename) === '.css';
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
+ }
19
25
 
20
- function rootConvertor(rootOriginal, defaultSelector, data, chunkFilename, excludeStrings) {
26
+ function rootConvertor(rootOriginal, defaultSelector, data, filename, excludeStrings) {
21
27
  rootOriginal.walkRules((rule, index) => {
22
28
  const prevNode = rootOriginal.nodes[index - 1];
23
29
 
@@ -31,14 +37,14 @@ function rootConvertor(rootOriginal, defaultSelector, data, chunkFilename, exclu
31
37
  }
32
38
  }
33
39
 
34
- if (excludeStrings.includes(rule.selector)) {
35
- return;
36
- }
37
-
38
40
  let ruleArr = rule.selector.split(',');
39
- ruleArr.forEach((rule, index) => {
40
- if (rule.includes(']')) {
41
- if (rule.slice(rule.lastIndexOf(']') + 2).trim() === '') {
41
+ ruleArr.forEach((ruleStr, index) => {
42
+ if (excludeStrings.includes(ruleStr.trim())) {
43
+ return;
44
+ }
45
+
46
+ if (ruleStr.includes(']')) {
47
+ if (ruleStr.slice(ruleStr.lastIndexOf(']') + 2).trim() === '') {
42
48
  return;
43
49
  } // console.log(
44
50
  // rule.slice(rule.lastIndexOf(']') + 2).trim(),
@@ -46,22 +52,34 @@ function rootConvertor(rootOriginal, defaultSelector, data, chunkFilename, exclu
46
52
  // );
47
53
 
48
54
 
49
- ruleArr[index] = `${rule.slice(0, rule.lastIndexOf(']') + 1).trim()} ${defaultSelector}${rule.slice(rule.lastIndexOf(']') + 2).trim()}`; // console.log(ruleArr[index]);
55
+ ruleArr[index] = `${ruleStr.slice(0, ruleStr.lastIndexOf(']') + 1).trim()} ${defaultSelector}${ruleStr.slice(ruleStr.lastIndexOf(']') + 2).trim()}`; // console.log(ruleArr[index]);
50
56
 
51
57
  return;
52
58
  }
53
59
 
54
- ruleArr[index] = data[chunkFilename] ? `${data[chunkFilename].defaultSelector}${rule}` : `${defaultSelector}${rule}`;
60
+ const keyMatch = checkFilename(filename, data);
61
+ ruleArr[index] = data[keyMatch] ? `${data[keyMatch].defaultSelector}${ruleStr}` : `${defaultSelector}${ruleStr}`;
55
62
  });
56
63
  rule.selector = ruleArr.join(',\n'); // console.log(`${rule.selector} converted`);
57
64
  });
58
65
  return rootOriginal;
59
66
  }
60
67
 
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
+
61
78
  class SelectorPlugin {
62
79
  constructor(options = {}) {
63
80
  this.optimize = options.optimize;
64
81
  this.selectorWeightConfig = options.selectorWeightConfig;
82
+ this.exclude = options.exclude;
65
83
  }
66
84
 
67
85
  apply(compiler) {
@@ -74,19 +92,47 @@ class SelectorPlugin {
74
92
  const rawdata = _fs.default.readFileSync(customFileDetails);
75
93
 
76
94
  const data = JSON.parse(rawdata);
95
+ this.exclude = (0, _windowsModification.windowsModification)(this.exclude);
77
96
  compiler.hooks.compilation.tap('selector-weight-rewrite', compilation => {
78
- compilation.hooks.optimizeChunkAssets.tapAsync('selector-weight-rewrite', (chunks, callback) => {
79
- chunks.forEach(chunk => {
80
- chunk.files.filter(isCss).forEach(chunkFilename => {
81
- const asset = compilation.assets[chunkFilename];
82
- const sourceStr = asset.source();
83
-
84
- const rootOriginal = _postcss.default.parse(sourceStr);
85
-
86
- compilation.assets[chunkFilename] = new _webpackSources.RawSource(rootConvertor(rootOriginal, defaultSelector, data, chunkFilename, excludeStrings).toString());
87
- });
97
+ // compilation.hooks.optimizeChunkAssets.tapAsync(
98
+ // 'selector-weight-rewrite',
99
+ // (chunks, callback) => {
100
+ // chunks.forEach(chunk => {
101
+ // chunk.files.filter(isCss).forEach(chunkFilename => {
102
+ // const asset = compilation.assets[chunkFilename];
103
+ // const sourceStr = asset.source();
104
+ // const rootOriginal = postcss.parse(sourceStr);
105
+ // compilation.assets[chunkFilename] = new RawSource(
106
+ // rootConvertor(
107
+ // rootOriginal,
108
+ // defaultSelector,
109
+ // data,
110
+ // chunkFilename,
111
+ // excludeStrings
112
+ // ).toString()
113
+ // );
114
+ // });
115
+ // });
116
+ // callback();
117
+ // }
118
+ // );
119
+ compilation.hooks.optimizeModules.tap('selector-weight-rewrite', modules => {
120
+ const mods = modules.filter(x => x.type.includes('css'));
121
+ mods.forEach(module => {
122
+ const rootOriginal = _postcss.default.parse(module.content);
123
+
124
+ const filename = module.issuer.resource;
125
+
126
+ if (!filename.includes('node_modules')) {
127
+ if (ignoreFile(this.exclude, filename)) {
128
+ return;
129
+ } // console.log(filename);
130
+
131
+
132
+ module.content = //new RawSource(
133
+ rootConvertor(rootOriginal, defaultSelector, data, filename, excludeStrings).toString(); // );
134
+ }
88
135
  });
89
- callback();
90
136
  });
91
137
  });
92
138
  }
@@ -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) {
@@ -26,15 +26,15 @@ const {
26
26
  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
27
  // -- is issue IO --
28
28
 
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
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
38
38
  */
39
39
 
40
40
  function isIgnoreValuePresent(ignoreVals, prop) {
@@ -47,14 +47,14 @@ function isIgnoreValuePresent(ignoreVals, prop) {
47
47
  return present;
48
48
  } // -- to convert the hyphen values to values --
49
49
 
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
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
58
58
  */
59
59
 
60
60
 
@@ -154,13 +154,13 @@ class VariableConversionCollector {
154
154
  }
155
155
  };
156
156
  }
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
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
164
164
  */
165
165
 
166
166
 
@@ -216,19 +216,19 @@ class VariableConversionCollector {
216
216
  });
217
217
  });
218
218
  });
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
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
232
232
  */
233
233
 
234
234
  Object.keys(variables).forEach(key => {
@@ -240,17 +240,17 @@ class VariableConversionCollector {
240
240
  });
241
241
  }); // -- conversion for the root using rootConvertor --
242
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
- }
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
+ }
254
254
  */
255
255
 
256
256
  compilation.hooks.optimizeModules.tap('VariableConversionCollector', modules => {
@@ -262,12 +262,12 @@ class VariableConversionCollector {
262
262
  });
263
263
  });
264
264
  });
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
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
271
271
  */
272
272
 
273
273
  compiler.hooks.afterEmit.tap('error-display', () => {
@@ -0,0 +1,37 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.default = void 0;
7
+
8
+ var _webpackSources = require("webpack-sources");
9
+
10
+ var _csso = require("csso");
11
+
12
+ class cssoPlugin {
13
+ apply(compiler) {
14
+ compiler.hooks.emit.tap('cssoPlugin', compilation => {
15
+ Object.keys(compilation.assets).forEach(filename => {
16
+ if (/\.css$/.test(filename)) {
17
+ // console.log(filename, ' processed!');
18
+ try {
19
+ let asset = compilation.assets[filename].source();
20
+
21
+ if (typeof asset !== 'string') {
22
+ asset = asset.toString();
23
+ }
24
+
25
+ const result = (0, _csso.minify)(asset).css;
26
+ compilation.assets[filename] = new _webpackSources.RawSource(result);
27
+ } catch (e) {
28
+ compilation.errors.push(e);
29
+ }
30
+ }
31
+ });
32
+ });
33
+ }
34
+
35
+ }
36
+
37
+ exports.default = cssoPlugin;
@@ -0,0 +1,57 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.checkPattern = checkPattern;
7
+ exports.negateArray = negateArray;
8
+
9
+ function checkPattern(filename, pattern) {
10
+ let isMatching = false;
11
+
12
+ if (pattern === '*') {
13
+ // console.log('case 3');
14
+ isMatching = true;
15
+ } else if (/^!/gi.test(pattern) && filename.includes(pattern)) {
16
+ // console.log('case 1');
17
+ isMatching = false;
18
+ } else if (!/^!/gi.test(pattern) && filename.includes(pattern)) {
19
+ // console.log('case 2');
20
+ isMatching = true;
21
+ }
22
+
23
+ return isMatching;
24
+ }
25
+
26
+ function negateArray(arr) {
27
+ const temp = [...arr];
28
+ temp.forEach((x, index) => {
29
+ if (/^!/gi.test(x)) {
30
+ arr[index] = x.substring(1);
31
+ } else {
32
+ arr[index] = `!${x}`;
33
+ }
34
+ });
35
+ return temp;
36
+ } // const pattern1 = ["*","src/","src/**/avatar","!src/components",];
37
+ // const examplesInputs1 = [
38
+ // "D:/Mywork/desk_client_app/src/components/component.css",
39
+ // "D:/Mywork/desk_client_app/src/components/avatar/avatar.css",
40
+ // "D:/Mywork/desk_client_app/src/components/teamavatar/avatar.css",
41
+ // "D:/Mywork/desk_client_app/src/container/teamavatar/avatar.css",
42
+ // "D:/Mywork/desk_client_app/deskapp/container/teamavatar/avatar.css",
43
+ // ]
44
+ // const pattern2 = ["src/","!src/components","src/components/avatar"];
45
+ // const examplesInputs2 = [
46
+ // "D:/Mywork/desk_client_app/src/components/component.css",
47
+ // "D:/Mywork/desk_client_app/src/components/avatar/avatar.css",
48
+ // "D:/Mywork/desk_client_app/src/components/teamavatar/avatar.css",
49
+ // "D:/Mywork/desk_client_app/src/container/teamavatar/avatar.css",
50
+ // "D:/Mywork/desk_client_app/deskapp/container/teamavatar/avatar.css",
51
+ // ]
52
+ // console.log(checkPattern('filename', ["*","src/","!src/components","src/components/avatar"]))
53
+ // console.log(checkPattern(filename, pattern))
54
+ // console.log(checkPattern(filename, pattern))
55
+ // console.log(checkPattern(filename, pattern))
56
+ // console.log(checkPattern(filename, pattern))
57
+ // console.log(checkPattern(filename, pattern))
@@ -0,0 +1,28 @@
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.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
+ let mediaQuery = false;
20
+
21
+ if (isAtRule(rule)) {
22
+ if (rule.parent.name === 'media') {
23
+ mediaQuery = true;
24
+ }
25
+ }
26
+
27
+ return mediaQuery;
28
+ }
@@ -0,0 +1,122 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.filterFile = filterFile;
7
+ exports.ignoreFile = ignoreFile;
8
+
9
+ var _windowsModification = require("../../loaderUtils/windowsModification");
10
+
11
+ var _checkPattern = require("./checkPattern");
12
+
13
+ const ignore = require('ignore');
14
+
15
+ function ignoreFile(excludeArr, filename) {
16
+ let ignore = false;
17
+ excludeArr.forEach(exclStr => {
18
+ if (filename.includes(exclStr)) {
19
+ ignore = true;
20
+ }
21
+ });
22
+ return ignore;
23
+ }
24
+
25
+ function checkFile(filename, arr) {
26
+ let include = false;
27
+ arr.forEach(val => {
28
+ if (val.includes('*')) {
29
+ return true;
30
+ }
31
+ });
32
+ }
33
+
34
+ function filterFile(filename, filterObject, plugins) {
35
+ // plugins.forEach(x => console.log(x.postcssPlugin));
36
+ // let acceptedPlugins = Object.keys()
37
+ let aliasNames = {
38
+ valueReplacer: 'postcss-value-replacer',
39
+ selectorReplace: 'postcss-selector-symbol-replace',
40
+ hasRTL: 'postcss-rtl',
41
+ combinerMediaQuery: 'postcss-combine-media-query',
42
+ hoverActive: 'postcss-mobile-hover',
43
+ cssVariableReplacement: 'postcss-variable-report' // hoverActive
44
+ // combinerMediaQuery
45
+ // rtl
46
+ // cssVariableReplacement
47
+ // selectorWeight
48
+
49
+ };
50
+ const finalPlugins = [];
51
+ Object.keys(filterObject).forEach(key => {
52
+ // console.log(key, filterObject[key], aliasNames);
53
+ // console.log(key);
54
+ plugins.forEach(x => {
55
+ let include = false;
56
+
57
+ if (aliasNames[key] === x.postcssPlugin) {
58
+ const includeVals = filterObject[key].filter(x => !/^!/gi.test(x));
59
+ const excludeVals = filterObject[key].filter(x => /^!/gi.test(x)); // console.log(includeVals, excludeVals);
60
+ // filterObject[key] = windowsModification(filterObject[key]);
61
+ // filterObject[key].forEach(pattern => {
62
+ // // console.log(x.postcssPlugin);
63
+ // // console.log(pattern);
64
+ // // console.log(
65
+ // // /^!/gi.test(pattern),
66
+ // // filename.includes(pattern),
67
+ // // filename,
68
+ // // pattern
69
+ // // );
70
+ // // include = checkPattern(filename, pattern);
71
+ // // if (pattern === '*') {
72
+ // // // console.log('case 3');
73
+ // // include = true;
74
+ // // } else if (/^!/gi.test(pattern) && filename.includes(pattern)) {
75
+ // // // console.log('case 1');
76
+ // // include = false;
77
+ // // } else if (!/^!/gi.test(pattern) && filename.includes(pattern)) {
78
+ // // // console.log('case 2');
79
+ // // include = true;
80
+ // // }
81
+ // });
82
+
83
+ let rootDir = 'supportapp';
84
+ const regex = `^(.+?)${rootDir}?\\\\`; // rootDir = rootDir.replace('/', '\\');
85
+ // console.log(regex, new RegExp(regex, 'gi'), filename.replace(new RegExp(regex, 'gi'), ''));
86
+
87
+ const newFilename = filename.replace(new RegExp(regex, 'gi'), ''); // console.log(negateArray(filterObject[key]));
88
+ // console.log(filterObject[key]);
89
+
90
+ const ig = ignore().add(filterObject[key]); // console.log(x.postcssPlugin, new RegExp(regex, 'gi'));
91
+ // console.log(filterObject[key]);
92
+ // if (!ig.ignores(newFilename)) {
93
+ // finalPlugins.push(x);
94
+ // }
95
+ // console.log(ig);
96
+ // console.log([filename].filter(filePathFilter({ include: includeVals, exclude: excludeVals })));
97
+ // if (ig.ignores(newFilename)) {
98
+ // console.log(ig.ignores(newFilename), newFilename);
99
+ // console.log('include this file', x.postcssPlugin);
100
+ // }
101
+ // console.log(x.postcssPlugin, filename, filterObject[key], include);
102
+ // if (include) {
103
+ // console.log('included: ', finalPlugins);
104
+ // console.log(filename);
105
+ // console.log('-------------------------------------------------------------------------------------------------')
106
+ // finalPlugins.push(x);
107
+ // }
108
+ }
109
+ });
110
+ }); // if (include) {
111
+ // console.log('before: ', plugins);
112
+ // console.log('after: ');
113
+ // console.log(finalPlugins);
114
+ // }
115
+ // console.log(filename);
116
+ // console.log(finalPlugins);
117
+ // console.log(
118
+ // '-------------------------------------------------------------------------------------------------'
119
+ // );
120
+
121
+ return finalPlugins; // console.log(filename, filterObject);
122
+ }