@zohodesk/react-cli 0.0.1-exp.175.1 → 0.0.1-exp.176.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (250) hide show
  1. package/.eslintignore +7 -7
  2. package/.eslintrc.js +180 -180
  3. package/.prettierrc +6 -6
  4. package/README.md +1025 -1028
  5. package/bin/cli.js +482 -482
  6. package/cert/Tsicsezwild-22-23.crt +37 -37
  7. package/cert/Tsicsezwild-22-23.key +27 -27
  8. package/docs/CustomChunks.md +26 -26
  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 -0
  13. package/docs/TODOS.md +10 -10
  14. package/docs/ValueReplacer.md +60 -60
  15. package/docs/VariableConversion.md +719 -678
  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/babel/cmjs-plugins-presets.js +4 -0
  20. package/lib/babel/es-plugins-presets.js +4 -0
  21. package/lib/common/getEntries.js +10 -0
  22. package/lib/common/getPublicPathConfig.js +6 -0
  23. package/lib/common/index.js +5 -0
  24. package/lib/common/splitChunks.js +13 -2
  25. package/lib/common/sslcertUpdater.js +17 -6
  26. package/lib/common/templateParameters.js +2 -0
  27. package/lib/common/testPattern.js +21 -10
  28. package/lib/common/valueReplacer.js +15 -0
  29. package/lib/configs/jest.config.js +9 -0
  30. package/lib/configs/libAlias.js +2 -4
  31. package/lib/configs/webpack.component.umd.config.js +5 -0
  32. package/lib/configs/webpack.css.umd.config.js +13 -5
  33. package/lib/configs/webpack.dev.config.js +36 -2
  34. package/lib/configs/webpack.docs.config.js +21 -1
  35. package/lib/configs/webpack.impact.config.js +19 -1
  36. package/lib/configs/webpack.prod.config.js +37 -3
  37. package/lib/hooks/docsProptypeHook.js +7 -3
  38. package/lib/jest/commitedFilesResult.js +45 -3
  39. package/lib/jest/coverageCollector.js +11 -0
  40. package/lib/jest/jsonMaker.js +6 -0
  41. package/lib/jest/preProcessors/cssPreprocessor.js +8 -0
  42. package/lib/jest/preProcessors/jsPreprocessor.js +2 -0
  43. package/lib/jest/preProcessors/otherFilesPreprocessor.js +3 -0
  44. package/lib/jest/result.js +22 -0
  45. package/lib/jest/run.js +17 -6
  46. package/lib/jest/setup.js +57 -5
  47. package/lib/loaderUtils/configsAssetsLoaders.js +44 -34
  48. package/lib/loaderUtils/getCSSLoaders.js +35 -20
  49. package/lib/loaderUtils/getDevJsLoaders.js +8 -0
  50. package/lib/loaderUtils/index.js +3 -0
  51. package/lib/loaderUtils/windowsModification.js +11 -0
  52. package/lib/loaders/docsLoader.js +7 -0
  53. package/lib/loaders/docsPropsLoader.js +7 -3
  54. package/lib/loaders/fileBountryLoader.js +2 -0
  55. package/lib/loaders/fileLoader.js +22 -11
  56. package/lib/loaders/scriptInstrumentLoader.js +13 -5
  57. package/lib/loaders/selectorMappingLoader.js +25 -7
  58. package/lib/loaders/workerLoader.js +29 -13
  59. package/lib/middlewares/HMRMiddleware.js +26 -13
  60. package/lib/middlewares/SSTMiddleware.js +3 -0
  61. package/lib/pluginUtils/configHtmlWebpackPlugins.js +9 -3
  62. package/lib/pluginUtils/getDevPlugins.js +68 -22
  63. package/lib/pluginUtils/getDocsPlugins.js +10 -1
  64. package/lib/pluginUtils/getLibraryImactPlugins.js +5 -4
  65. package/lib/pluginUtils/getLibraryPlugins.js +5 -0
  66. package/lib/pluginUtils/getProdPlugins.js +77 -28
  67. package/lib/pluginUtils/getServerPlugins.js +5 -0
  68. package/lib/pluginUtils/getUMDCSSPlugins.js +7 -0
  69. package/lib/pluginUtils/getUMDComponentPlugins.js +7 -0
  70. package/lib/pluginUtils/index.js +8 -0
  71. package/lib/plugins/CdnChangePlugin.js +14 -0
  72. package/lib/plugins/CleanupStatsPlugin.js +5 -0
  73. package/lib/plugins/EFCPlugin.js +34 -23
  74. package/lib/plugins/EFCPlugin.md +6 -6
  75. package/lib/plugins/EFCTemplatePlugin.js +32 -23
  76. package/lib/plugins/I18NInjectIntoIndexPlugin.js +38 -12
  77. package/lib/plugins/I18nSplitPlugin/I18nDebugPlugin.js +17 -12
  78. package/lib/plugins/I18nSplitPlugin/I18nDependency.js +10 -4
  79. package/lib/plugins/I18nSplitPlugin/I18nDownlodLogic.js +77 -46
  80. package/lib/plugins/I18nSplitPlugin/I18nFilesEmitter.js +59 -44
  81. package/lib/plugins/I18nSplitPlugin/I18nKeysIdentifer.js +30 -21
  82. package/lib/plugins/I18nSplitPlugin/I18nSplit.md +95 -95
  83. package/lib/plugins/I18nSplitPlugin/README.md +25 -25
  84. package/lib/plugins/I18nSplitPlugin/index.js +80 -70
  85. package/lib/plugins/I18nSplitPlugin/utils/collectI18nKeys.js +12 -2
  86. package/lib/plugins/I18nSplitPlugin/utils/getI18nFileUrlPathTemplate.js +1 -0
  87. package/lib/plugins/I18nSplitPlugin/utils/getI18nKeysFormModules.js +5 -0
  88. package/lib/plugins/I18nSplitPlugin/utils/hashUtils.js +6 -0
  89. package/lib/plugins/I18nSplitPlugin/utils/index.js +4 -0
  90. package/lib/plugins/I18nSplitPlugin/utils/propertiesUtils.js +20 -2
  91. package/lib/plugins/ManifestPlugin.js +17 -0
  92. package/lib/plugins/ModuleStatsPlugin.js +23 -0
  93. package/lib/plugins/OptimizeJSPlugin.js +7 -0
  94. package/lib/plugins/PublicPathCallbackPlugin.js +10 -0
  95. package/lib/plugins/PublicPathChangePlugin.js +36 -4
  96. package/lib/plugins/ReportGeneratePlugin.js +30 -4
  97. package/lib/plugins/RequireVariablePublicPlugin.js +6 -0
  98. package/lib/plugins/ResourceHintsPlugin.js +27 -20
  99. package/lib/plugins/RtlSplitPlugin/OverwriteCssPathForRTL.js +17 -12
  100. package/lib/plugins/RtlSplitPlugin/RtlCssPlugin.js +22 -15
  101. package/lib/plugins/RtlSplitPlugin/RtrSplit.md +30 -30
  102. package/lib/plugins/RtlSplitPlugin/replaceCssDirTemplate.js +5 -2
  103. package/lib/plugins/ScriptInstrumentPlugin.js +7 -0
  104. package/lib/plugins/SelectorPlugin.js +97 -0
  105. package/lib/plugins/ServiceWorkerPlugin.js +29 -13
  106. package/lib/plugins/ShadowDOMSupportPlugin.js +40 -3
  107. package/lib/plugins/SourceMapHookPlugin.js +9 -0
  108. package/lib/plugins/TPHashMappingPlugin.js +19 -5
  109. package/lib/plugins/UglifyCSSPlugin.js +9 -0
  110. package/lib/plugins/UnusedFilesFindPlugin.js +35 -2
  111. package/lib/plugins/VariableConversionCollector.js +322 -0
  112. package/lib/plugins/composeCommonPlugin.js +30 -0
  113. package/lib/plugins/index.js +19 -0
  114. package/lib/plugins/libraryImpactPlugin.js +32 -0
  115. package/lib/plugins/webpackwatchrunplugin.js +5 -0
  116. package/lib/postcss-plugins/ExcludePlugin.js +4 -0
  117. package/lib/postcss-plugins/RTLSplitPlugin.js +37 -24
  118. package/lib/postcss-plugins/ValueReplacer.js +6 -9
  119. package/lib/postcss-plugins/__test__/hoverActivePlugin.spec.js +3 -0
  120. package/lib/postcss-plugins/__test__/test1Input.css +38 -38
  121. package/lib/postcss-plugins/__test__/test1Output.css +38 -38
  122. package/lib/postcss-plugins/hoverActivePlugin.js +69 -33
  123. package/lib/postcss-plugins/variableModificationPlugin/ErrorHandler.js +42 -13
  124. package/lib/postcss-plugins/variableModificationPlugin/index.js +216 -141
  125. package/lib/postcss-plugins/variableModifier.js +20 -13
  126. package/lib/schemas/index.js +23 -4
  127. package/lib/servers/clusterHubServer.js +10 -0
  128. package/lib/servers/devBuild.js +24 -13
  129. package/lib/servers/docsServer.js +2 -0
  130. package/lib/servers/docsServerCore.js +21 -0
  131. package/lib/servers/getCliPath.js +9 -0
  132. package/lib/servers/helpServer.js +5 -0
  133. package/lib/servers/httpsOptions.js +4 -0
  134. package/lib/servers/impactServer.js +34 -2
  135. package/lib/servers/mockserver.js +9 -0
  136. package/lib/servers/nowatchserver.js +34 -12
  137. package/lib/servers/scrServer.js +20 -13
  138. package/lib/servers/server.js +35 -7
  139. package/lib/servers/ssServer.js +16 -0
  140. package/lib/sh/pre-commit.sh +34 -34
  141. package/lib/sh/reportPublish.sh +45 -45
  142. package/lib/templates/CoverageScriptTemplate.js +14 -0
  143. package/lib/templates/WMSTemplate.js +12 -6
  144. package/lib/utils/babelPresets.js +2 -0
  145. package/lib/utils/buildstats.html +148 -148
  146. package/lib/utils/clean.js +8 -2
  147. package/lib/utils/copy.js +6 -0
  148. package/lib/utils/copyTimezones.js +8 -0
  149. package/lib/utils/createEventStream.js +4 -0
  150. package/lib/utils/cssClassNameGenerate.js +19 -3
  151. package/lib/utils/cssURLReplacer.js +25 -0
  152. package/lib/utils/dependencyPostPublish.js +9 -0
  153. package/lib/utils/fileUtils.js +26 -0
  154. package/lib/utils/folderIterator.js +10 -0
  155. package/lib/utils/getComponents.js +21 -0
  156. package/lib/utils/getCurrentBranch.js +5 -0
  157. package/lib/utils/getDependenciesImpactList.js +21 -0
  158. package/lib/utils/getHash.js +7 -0
  159. package/lib/utils/getIp.js +2 -0
  160. package/lib/utils/getOptions.js +39 -14
  161. package/lib/utils/getServerURL.js +7 -0
  162. package/lib/utils/index.js +47 -2
  163. package/lib/utils/init.js +1 -0
  164. package/lib/utils/initPreCommitHook.js +29 -6
  165. package/lib/utils/jsonHelper.js +19 -2
  166. package/lib/utils/libraryImpactConfig.js +2 -0
  167. package/lib/utils/lint/addScripts.js +5 -2
  168. package/lib/utils/lint/checkExistingConfig.js +12 -3
  169. package/lib/utils/lint/copyConfigs.js +3 -0
  170. package/lib/utils/lint/index.js +9 -0
  171. package/lib/utils/lint/lintScripts.js +1 -0
  172. package/lib/utils/lint/lintSetup.js +4 -3
  173. package/lib/utils/lint/lintStagedPreCommitHook.js +1 -0
  174. package/lib/utils/lint/question.js +7 -0
  175. package/lib/utils/lintReporter.js +20 -0
  176. package/lib/utils/mailSender.js +7 -0
  177. package/lib/utils/pullOrigin.js +4 -0
  178. package/lib/utils/reinstallDependencies.js +28 -0
  179. package/lib/utils/removeAttributes.js +7 -0
  180. package/lib/utils/repoClone.js +27 -2
  181. package/lib/utils/request.js +12 -0
  182. package/lib/utils/resultSchema.json +73 -73
  183. package/lib/utils/rtl.js +16 -4
  184. package/lib/utils/setEnvVariables.js +2 -0
  185. package/lib/utils/ssTestHack.js +10 -0
  186. package/lib/utils/switchBranch.js +4 -0
  187. package/lib/utils/urlConcat.js +4 -0
  188. package/lib/utils/useExitCleanup.js +10 -9
  189. package/npm8.md +9 -9
  190. package/package.json +146 -146
  191. package/postpublish.js +6 -6
  192. package/templates/app/.eslintrc.js +140 -140
  193. package/templates/app/README.md +12 -12
  194. package/templates/app/app/index.html +24 -24
  195. package/templates/app/app/properties/ApplicationResources_en_US.properties +1 -1
  196. package/templates/app/app/properties/i18nkeys.json +3 -3
  197. package/templates/app/docs/all.html +69 -69
  198. package/templates/app/mockapi/index.js +18 -18
  199. package/templates/app/package.json +37 -37
  200. package/templates/app/src/actions/SampleActions/index.js +37 -37
  201. package/templates/app/src/actions/index.js +65 -65
  202. package/templates/app/src/appUrls.js +19 -19
  203. package/templates/app/src/components/Alert/Alert.js +134 -134
  204. package/templates/app/src/components/Alert/Alert.module.css +79 -79
  205. package/templates/app/src/components/FreezeLayer/FreezeLayer.css +37 -37
  206. package/templates/app/src/components/FreezeLayer/FreezeLayer.js +84 -84
  207. package/templates/app/src/components/Sample/Sample.module.css +11 -11
  208. package/templates/app/src/components/Sample/SampleList.js +61 -61
  209. package/templates/app/src/components/Slider/Slider.css +41 -41
  210. package/templates/app/src/components/Slider/Slider.js +55 -55
  211. package/templates/app/src/containers/AlertContainer/index.js +15 -15
  212. package/templates/app/src/containers/AppContainer/index.js +96 -96
  213. package/templates/app/src/containers/AppContainer/index.module.css +27 -27
  214. package/templates/app/src/containers/CustomMatch/index.js +65 -65
  215. package/templates/app/src/containers/DevTools/index.js +10 -10
  216. package/templates/app/src/containers/Header/index.js +67 -67
  217. package/templates/app/src/containers/Header/index.module.css +43 -43
  218. package/templates/app/src/containers/Redirect/index.js +63 -63
  219. package/templates/app/src/containers/Redirector/index.js +47 -47
  220. package/templates/app/src/containers/SampleListContainer/ListContainer.js +42 -42
  221. package/templates/app/src/containers/SampleListContainer/ListContainer.module.css +3 -3
  222. package/templates/app/src/historyChange.js +5 -5
  223. package/templates/app/src/index.html +10 -10
  224. package/templates/app/src/index.js +24 -24
  225. package/templates/app/src/middleware/PromiseMiddleware.js +59 -59
  226. package/templates/app/src/reducers/alertData.js +11 -11
  227. package/templates/app/src/reducers/index.js +6 -6
  228. package/templates/app/src/reducers/samples.js +19 -19
  229. package/templates/app/src/store/configureStore.dev.js +51 -51
  230. package/templates/app/src/store/configureStore.js +5 -5
  231. package/templates/app/src/store/configureStore.prod.js +26 -26
  232. package/templates/app/src/util/Common.js +5 -5
  233. package/templates/app/src/util/RequestAPI.js +132 -132
  234. package/templates/docs/all.html +249 -249
  235. package/templates/docs/component.html +178 -178
  236. package/templates/docs/components.html +221 -221
  237. package/templates/docs/css/b.min.css +6 -6
  238. package/templates/docs/css/component.css +42 -42
  239. package/templates/docs/css/componentTest.css +6 -6
  240. package/templates/docs/css/hopscotch.css +585 -585
  241. package/templates/docs/css/style.css +1022 -1022
  242. package/templates/docs/impactReportTemplate.html +154 -154
  243. package/templates/docs/index.html +1501 -1501
  244. package/templates/docs/js/active-line.js +72 -72
  245. package/templates/docs/js/b.min.js +7 -7
  246. package/templates/docs/js/codemirror.js +9680 -9680
  247. package/templates/docs/js/designTokens.js +334 -334
  248. package/templates/docs/js/j.min.js +4 -4
  249. package/templates/docs/js/javascript.js +874 -874
  250. package/templates/docs/js/matchbrackets.js +145 -145
@@ -1,678 +1,719 @@
1
- # Variable Conversion
2
-
3
- <!-- file paths :
4
-
5
- # react - cli :
6
- src\postcss-plugins\variableModificationPlugin\index.js
7
-
8
- # source folder :
9
- jsapps\supportapp\cssVariableReplacementOptions.json ( options json file )
10
- jsapps\supportapp\plugins\pxParserPostcss.js ( px parsing as a process before plugin conversion to custom css variables in react -cli )
11
- jsapps\supportapp\plugins\variableIgnore.js ( adding variable:ignore comment to ignore the line for any conversion beforehand to preserve the declaration )
12
-
13
- -->
14
-
15
- # Added support for Properties ( Cut 1 ) :
16
-
17
- * font-size
18
- * margin
19
- * margin-top
20
- * margin-bottom
21
- * margin-left
22
- * margin-right
23
- * padding
24
- * padding-top
25
- * padding-bottom
26
- * padding-left
27
- * padding-right
28
- * top
29
- * right
30
- * bottom
31
- * left
32
- * width
33
- * min-width
34
- * max-width
35
- * height
36
- * min-height
37
- * max-height
38
-
39
- # Css variable conversion consists of three steps :
40
-
41
- . addition of comment variable:ignore for the seperation of values to be considered for the conversion and the ones that are not to be considered for conversion. ( `variableIgnore.js` )
42
- . conversion of the variable from current css variables to corresponding px value manually. ( `pxParserPostcss.js` )
43
- . conversion of the resultant px values to custom variables present in settings ( `cssVariableReplacementOptions.json` )
44
-
45
- `cssVariableReplacementOptions.json example` :
46
-
47
- ```json
48
- {
49
- "errorLog": false,
50
- "errorInConsole": false,
51
- "errorsAllowed":{
52
- "DECLARATION_IGNORED" : true,
53
- "UNIT_ERROR" : true,
54
- "RANGE_ERROR" : true,
55
- "VARIABLE_PRESENT" : true
56
- },
57
- "settings": {
58
- "font-size": {
59
- "allowed": [
60
- "px",
61
- "em",
62
- "%",
63
- "0",
64
- "vh",
65
- "initial"
66
- ],
67
- "replacements": {
68
- "px": "var(--zd_font_size$$)",
69
- "em": "var(--zd_font_size$$em)"
70
- },
71
- "range": {
72
- "start": 0,
73
- "end": 1650
74
- }
75
- },
76
- "margin": {
77
- "allowed": [
78
- "px",
79
- "em",
80
- "fit-content",
81
- "auto",
82
- "%",
83
- "inherit",
84
- "-moz-fit-content",
85
- "vh",
86
- "0",
87
- "initial",
88
- "vw"
89
- ],
90
- "replacements": {
91
- "px": "var(--zd_size$$)"
92
- },
93
- "range": {
94
- "start": -1650,
95
- "end": 1650
96
- }
97
- },
98
- "margin-left": {
99
- "allowed": [
100
- "px",
101
- "em",
102
- "fit-content",
103
- "auto",
104
- "%",
105
- "inherit",
106
- "-moz-fit-content",
107
- "vh",
108
- "0",
109
- "initial",
110
- "vw"
111
- ],
112
- "replacements": {
113
- "px": "var(--zd_size$$)"
114
- },
115
- "range": {
116
- "start": -1650,
117
- "end": 1650
118
- }
119
- },
120
- "margin-right": {
121
- "allowed": [
122
- "px",
123
- "em",
124
- "fit-content",
125
- "auto",
126
- "%",
127
- "inherit",
128
- "-moz-fit-content",
129
- "vh",
130
- "0",
131
- "initial",
132
- "vw"
133
- ],
134
- "replacements": {
135
- "px": "var(--zd_size$$)"
136
- },
137
- "range": {
138
- "start": -1650,
139
- "end": 1650
140
- }
141
- },
142
- "margin-top": {
143
- "allowed": [
144
- "px",
145
- "em",
146
- "fit-content",
147
- "auto",
148
- "%",
149
- "inherit",
150
- "-moz-fit-content",
151
- "vh",
152
- "0",
153
- "initial",
154
- "vw"
155
- ],
156
- "replacements": {
157
- "px": "var(--zd_size$$)"
158
- },
159
- "range": {
160
- "start": -1650,
161
- "end": 1650
162
- }
163
- },
164
- "margin-bottom": {
165
- "allowed": [
166
- "px",
167
- "em",
168
- "fit-content",
169
- "auto",
170
- "%",
171
- "inherit",
172
- "-moz-fit-content",
173
- "vh",
174
- "0",
175
- "initial",
176
- "vw"
177
- ],
178
- "replacements": {
179
- "px": "var(--zd_size$$)"
180
- },
181
- "range": {
182
- "start": -1650,
183
- "end": 1650
184
- }
185
- },
186
- "padding": {
187
- "allowed": [
188
- "px",
189
- "em",
190
- "fit-content",
191
- "auto",
192
- "%",
193
- "inherit",
194
- "-moz-fit-content",
195
- "vh",
196
- "0",
197
- "initial",
198
- "vw"
199
- ],
200
- "replacements": {
201
- "px": "var(--zd_size$$)"
202
- },
203
- "range": {
204
- "start": -1650,
205
- "end": 1650
206
- }
207
- },
208
- "padding-left": {
209
- "allowed": [
210
- "px",
211
- "em",
212
- "fit-content",
213
- "auto",
214
- "%",
215
- "inherit",
216
- "-moz-fit-content",
217
- "vh",
218
- "0",
219
- "initial",
220
- "vw"
221
- ],
222
- "replacements": {
223
- "px": "var(--zd_size$$)"
224
- },
225
- "range": {
226
- "start": -1650,
227
- "end": 1650
228
- }
229
- },
230
- "padding-right": {
231
- "allowed": [
232
- "px",
233
- "em",
234
- "fit-content",
235
- "auto",
236
- "%",
237
- "inherit",
238
- "-moz-fit-content",
239
- "vh",
240
- "0",
241
- "initial",
242
- "vw"
243
- ],
244
- "replacements": {
245
- "px": "var(--zd_size$$)"
246
- },
247
- "range": {
248
- "start": -1650,
249
- "end": 1650
250
- }
251
- },
252
- "padding-top": {
253
- "allowed": [
254
- "px",
255
- "em",
256
- "fit-content",
257
- "auto",
258
- "%",
259
- "inherit",
260
- "-moz-fit-content",
261
- "vh",
262
- "0",
263
- "initial",
264
- "vw"
265
- ],
266
- "replacements": {
267
- "px": "var(--zd_size$$)"
268
- },
269
- "range": {
270
- "start": -1650,
271
- "end": 1650
272
- }
273
- },
274
- "padding-bottom": {
275
- "allowed": [
276
- "px",
277
- "em",
278
- "fit-content",
279
- "auto",
280
- "%",
281
- "inherit",
282
- "-moz-fit-content",
283
- "vh",
284
- "0",
285
- "initial",
286
- "vw"
287
- ],
288
- "replacements": {
289
- "px": "var(--zd_size$$)"
290
- },
291
- "range": {
292
- "start": -1650,
293
- "end": 1650
294
- }
295
- },
296
- "height": {
297
- "allowed": [
298
- "px",
299
- "em",
300
- "fit-content",
301
- "auto",
302
- "%",
303
- "inherit",
304
- "-moz-fit-content",
305
- "vh",
306
- "0",
307
- "initial",
308
- "vw"
309
- ],
310
- "replacements": {
311
- "px": "var(--zd_size$$)"
312
- },
313
- "range": {
314
- "start": -1650,
315
- "end": 1650
316
- }
317
- },
318
- "width": {
319
- "allowed": [
320
- "px",
321
- "em",
322
- "fit-content",
323
- "auto",
324
- "%",
325
- "inherit",
326
- "-moz-fit-content",
327
- "vh",
328
- "0",
329
- "initial",
330
- "vw"
331
- ],
332
- "replacements": {
333
- "px": "var(--zd_size$$)"
334
- },
335
- "range": {
336
- "start": -1650,
337
- "end": 1650
338
- }
339
- },
340
- "min-width": {
341
- "allowed": [
342
- "px",
343
- "em",
344
- "fit-content",
345
- "auto",
346
- "%",
347
- "inherit",
348
- "-moz-fit-content",
349
- "vh",
350
- "0",
351
- "initial",
352
- "vw"
353
- ],
354
- "replacements": {
355
- "px": "var(--zd_size$$)"
356
- },
357
- "range": {
358
- "start": -1650,
359
- "end": 1650
360
- }
361
- },
362
- "max-width": {
363
- "allowed": [
364
- "px",
365
- "em",
366
- "fit-content",
367
- "auto",
368
- "%",
369
- "inherit",
370
- "-moz-fit-content",
371
- "vh",
372
- "0",
373
- "initial",
374
- "vw"
375
- ],
376
- "replacements": {
377
- "px": "var(--zd_size$$)"
378
- },
379
- "range": {
380
- "start": -1650,
381
- "end": 1650
382
- }
383
- },
384
- "min-height": {
385
- "allowed": [
386
- "px",
387
- "em",
388
- "fit-content",
389
- "auto",
390
- "%",
391
- "inherit",
392
- "-moz-fit-content",
393
- "vh",
394
- "0",
395
- "initial",
396
- "vw"
397
- ],
398
- "replacements": {
399
- "px": "var(--zd_size$$)"
400
- },
401
- "range": {
402
- "start": -1650,
403
- "end": 1650
404
- }
405
- },
406
- "max-height": {
407
- "allowed": [
408
- "px",
409
- "em",
410
- "fit-content",
411
- "auto",
412
- "%",
413
- "inherit",
414
- "-moz-fit-content",
415
- "vh",
416
- "0",
417
- "initial",
418
- "vw"
419
- ],
420
- "replacements": {
421
- "px": "var(--zd_size$$)"
422
- },
423
- "range": {
424
- "start": -1650,
425
- "end": 1650
426
- }
427
- },
428
- "top": {
429
- "allowed": [
430
- "px",
431
- "em",
432
- "fit-content",
433
- "auto",
434
- "%",
435
- "inherit",
436
- "-moz-fit-content",
437
- "vh",
438
- "0",
439
- "initial",
440
- "vw"
441
- ],
442
- "replacements": {
443
- "px": "var(--zd_size$$)"
444
- },
445
- "range": {
446
- "start": -1650,
447
- "end": 1650
448
- }
449
- },
450
- "bottom": {
451
- "allowed": [
452
- "px",
453
- "em",
454
- "fit-content",
455
- "auto",
456
- "%",
457
- "inherit",
458
- "-moz-fit-content",
459
- "vh",
460
- "0",
461
- "initial",
462
- "vw"
463
- ],
464
- "replacements": {
465
- "px": "var(--zd_size$$)"
466
- },
467
- "range": {
468
- "start": -1650,
469
- "end": 1650
470
- }
471
- },
472
- "left": {
473
- "allowed": [
474
- "px",
475
- "em",
476
- "fit-content",
477
- "auto",
478
- "%",
479
- "inherit",
480
- "-moz-fit-content",
481
- "vh",
482
- "0",
483
- "initial",
484
- "vw"
485
- ],
486
- "replacements": {
487
- "px": "var(--zd_size$$)"
488
- },
489
- "range": {
490
- "start": -1650,
491
- "end": 1650
492
- }
493
- },
494
- "right": {
495
- "allowed": [
496
- "px",
497
- "em",
498
- "fit-content",
499
- "auto",
500
- "%",
501
- "inherit",
502
- "-moz-fit-content",
503
- "vh",
504
- "0",
505
- "initial",
506
- "vw"
507
- ],
508
- "replacements": {
509
- "px": "var(--zd_size$$)"
510
- },
511
- "range": {
512
- "start": -1650,
513
- "end": 1650
514
- }
515
- }
516
- }
517
- }
518
- ```
519
-
520
- Step 1 : Adding variable:ignore
521
-
522
- use command `npm run variable:addignore` on source folder
523
-
524
- before :
525
- ```css
526
- .a{
527
- font-size: var(--zd_size14);
528
- margin: var(--zd_size12);
529
- padding: 12px;
530
- }
531
- ```
532
-
533
- after :
534
-
535
- ```css
536
- /* explanation : since padding has declaration in px instead of var, it is considered unique and thereby no conversion should take place, hence we add variable:ignore preceding the line */
537
- .a{
538
- font-size: var(--zd_size14);
539
- margin: var(--zd_size12);
540
- /*Variable:Ignore*/
541
- padding: 12px;
542
- }
543
- ```
544
-
545
- Step 2 : Converting vars to px
546
-
547
- use command `npm run variable:convert` on source folder
548
-
549
- before :
550
- ```css
551
- .a{
552
- font-size: var(--zd_size14);
553
- margin: var(--zd_size12);
554
- /*Variable:Ignore*/
555
- padding: 12px;
556
- }
557
- ```
558
-
559
- after :
560
- ```css
561
- /* explanation : conversion from vars to px is done making the declarations convertable to custom variables further by the react-cli plugin*/
562
- .a{
563
- font-size: 14px;
564
- margin: 12px;
565
- /*Variable:Ignore*/
566
- padding: 12px;
567
- }
568
- ```
569
-
570
- Step 3 : Conversion from px to custom variables present in settings
571
-
572
- Things that are considered in the conversion :
573
- => `allowed` is the allowed units that can be converted through the plugin
574
- => `replacements` are the conversion strings where `$$` will be converted to respective numbers
575
- => `range` is the starting and ending value within numbers will be allowed.
576
-
577
- `variableModificationPlugin` in react-cli folder is where the conversion takes place.
578
-
579
- and output would be as follows :
580
-
581
- before :
582
-
583
- ```css
584
- /* explanation : conversion from px to variable is allowed since, all the conditions for font-size and margin are satisfied, the numbers are within range and the unit is in the allowed array, replacements are thereby taken from the values in replacements and conversion is done to custom variables */
585
-
586
- /*
587
- "font-size": {
588
- "allowed": [
589
- "px",
590
- "em",
591
- "%",
592
- "0",
593
- "vh",
594
- "initial"
595
- ],
596
- "replacements": {
597
- "px": "var(--zd_font_size$$)",
598
- "em": "var(--zd_font_size$$em)"
599
- },
600
- "range": {
601
- "start": 0,
602
- "end": 1650
603
- }
604
- },
605
- */
606
- /*
607
-
608
- "margin": {
609
- "allowed": [
610
- "px",
611
- "em",
612
- "fit-content",
613
- "auto",
614
- "%",
615
- "inherit",
616
- "-moz-fit-content",
617
- "vh",
618
- "0",
619
- "initial",
620
- "vw"
621
- ],
622
- "replacements": {
623
- "px": "var(--zd_size$$)"
624
- },
625
- "range": {
626
- "start": -1650,
627
- "end": 1650
628
- }
629
- },
630
-
631
- */
632
- .a{
633
- font-size: 14px;
634
- margin: 12px;
635
- /*Variable:Ignore*/
636
- padding: 12px;
637
- }
638
- ```
639
-
640
- after :
641
-
642
- ```css
643
-
644
- .a{
645
- font-size: var(--zd_size14);
646
- margin: var(--zd_size12);
647
- /*Variable:Ignore*/
648
- padding: 12px;
649
- }
650
- ```
651
-
652
- Output configuration :
653
-
654
- Consider the below mentioned :
655
- ```json
656
- "errorLog": false,
657
- "errorInConsole": false,
658
- "errorsAllowed":{
659
- "DECLARATION_IGNORED" : true,
660
- "UNIT_ERROR" : true,
661
- "RANGE_ERROR" : true,
662
- "VARIABLE_PRESENT" : true
663
- },
664
- ```
665
- . if an error log is necessary, a physical file `css_error.log` will be created in the source directory upon making `errorLog` true. will take generally more than usual time to write in the file, so delay in build is present.
666
-
667
- . if error is needed to be seen in the console, `errorInConsole` should be enabled, all errors will be printed in the console.
668
-
669
- . Individual errors can be enabled in `errorsAllowed` to collaboratively produce the error log file / errors in console. Here each of the errors mean the following :
670
-
671
- => `DECLARATION_IGNORED` : Lines that succeed the /*Variable:Ignore*/ comment.
672
- => `UNIT_ERROR` : the units that are not present in the corresponding property's `allowed` array are used.
673
- => `RANGE_ERROR` : numerical values that are not present within the range of the corresponding property's `range` is used.
674
- => `VARIABLE_PRESENT` : conversion to px (Step 2) wasn't done properly and hence there are residues that contain `var` in it are found.
675
-
676
-
677
- * First two conversions are to be done manually by the use of the commands, `npm run variable:addignore` and `npm run variable:convert`
678
- * Final conversion is done by react-cli on compilation of the source folder `npm run start --app:port=**** --app:domain=****`
1
+ # Variable Conversion
2
+
3
+ ## Overview
4
+
5
+ Conversion for Variables from Variables to px in Supportapp completed (`variableIgnore.js` && `pxParserPostcss.js` to be referred to), and px to custom variables through the new `variableModificationPlugin`. Error Log generation can also be converted on enabling
6
+
7
+ **Features:**
8
+ # Features below are added form `0.0.1-beta.173`
9
+ 1. variables are converted from px to custom variables ( options are consumed from `cssVariableReplacementOptions.json` present in source folder )
10
+ 2. To enable the error log generation `errorLog` is to be made `true` in `cssVariableReplacementOptions.json` ( it will take a little longer than usual build time )
11
+ 3. To enable the console display of errors that are generated, `errorInConsole` is to be made `true` in `cssVariableReplacementOptions.json`
12
+ 4. To enable specific errors in the error log generation / error display on console, `DECLARATION_IGNORED`(for ignoring that particular line / declaration),`UNIT_ERROR` (when the Unit doesnt match the available units for the property),`RANGE_ERROR` (when the value does not fall within the range that is given for the property), `VARIABLE_PRESENT`(whether the value supposed to be in px for conversion sake is not converted from var() to px or if it's properly converted to px for conversion from px to var through our plugin) are to be individually made `true` in `cssVariableReplacementOptions.json`
13
+
14
+ # Features below are added form `0.0.1-beta.176`
15
+
16
+ * variables with -- are now supported due to the webpack plugin `VariableConversionCollector` that is generated for the same.
17
+ * `DECIMAL_CHECK`, `DECIMAL_REJECT` are two new errors supported.
18
+ * support for text-indent, clip, flex, flex-basis, row-gap, column-gap, gap properties are now given.
19
+
20
+ # Features below are added form `0.0.1-beta.177`
21
+
22
+ * new Error `MULTIPLE_OCCURANCES` supported.
23
+ * In case css --variables are not assigned an error will be thrown. The unassigned variables can be manually assigned in `variableMapping.json`
24
+ For more information and reference, refer to `[details](https://zgit.csez.zohocorpin.com/zohodesk/react-cli/-/blob/2.0.0/docs/VariableConversion.md)
25
+
26
+
27
+ <!-- file paths :
28
+
29
+ # react - cli :
30
+ src\postcss-plugins\variableModificationPlugin\index.js
31
+
32
+ # source folder :
33
+ jsapps\supportapp\cssVariableReplacementOptions.json ( options json file )
34
+ jsapps\supportapp\plugins\pxParserPostcss.js ( px parsing as a process before plugin conversion to custom css variables in react -cli )
35
+ jsapps\supportapp\plugins\variableIgnore.js ( adding variable:ignore comment to ignore the line for any conversion beforehand to preserve the declaration )
36
+
37
+ -->
38
+
39
+ # Added support for Properties ( Cut 1 ) : (0.0.1-beta.173)
40
+
41
+ * font-size
42
+ * margin
43
+ * margin-top
44
+ * margin-bottom
45
+ * margin-left
46
+ * margin-right
47
+ * padding
48
+ * padding-top
49
+ * padding-bottom
50
+ * padding-left
51
+ * padding-right
52
+ * top
53
+ * right
54
+ * bottom
55
+ * left
56
+ * width
57
+ * min-width
58
+ * max-width
59
+ * height
60
+ * min-height
61
+ * max-height
62
+
63
+ # Added support for Properties ( Cut 2 ) : (0.0.1-beta.176)
64
+
65
+ * text-indent
66
+ * clip
67
+ * flex
68
+ * flex-basis
69
+ * row-gap
70
+ * column-gap
71
+ * gap
72
+
73
+ # Css variable conversion consists of three steps :
74
+
75
+ . addition of comment variable:ignore for the seperation of values to be considered for the conversion and the ones that are not to be considered for conversion. ( `variableIgnore.js` )
76
+ . conversion of the variable from current css variables to corresponding px value manually. ( `pxParserPostcss.js` )
77
+ . conversion of the resultant px values to custom variables present in settings ( `cssVariableReplacementOptions.json` )
78
+
79
+ `cssVariableReplacementOptions.json example` :
80
+
81
+ ```json
82
+ {
83
+ "errorLog": false,
84
+ "errorInConsole": false,
85
+ "errorsAllowed":{
86
+ "DECLARATION_IGNORED": true,
87
+ "UNIT_ERROR": true,
88
+ "DECIMAL_CHECK": true,
89
+ "DECIMAL_REJECT": true,
90
+ "RANGE_ERROR": true,
91
+ "VARIABLE_PRESENT": true,
92
+ "MULTIPLE_OCCURANCES": false
93
+ },
94
+ "settings": {
95
+ "font-size": {
96
+ "allowed": [
97
+ "px",
98
+ "em",
99
+ "%",
100
+ "0",
101
+ "vh",
102
+ "initial"
103
+ ],
104
+ "replacements": {
105
+ "px": "var(--zd_font_size$$)",
106
+ "em": "var(--zd_font_size$$em)"
107
+ },
108
+ "range": {
109
+ "start": 0,
110
+ "end": 1650
111
+ }
112
+ },
113
+ "margin": {
114
+ "allowed": [
115
+ "px",
116
+ "em",
117
+ "fit-content",
118
+ "auto",
119
+ "%",
120
+ "inherit",
121
+ "-moz-fit-content",
122
+ "vh",
123
+ "0",
124
+ "initial",
125
+ "vw"
126
+ ],
127
+ "replacements": {
128
+ "px": "var(--zd_size$$)"
129
+ },
130
+ "range": {
131
+ "start": -1650,
132
+ "end": 1650
133
+ }
134
+ },
135
+ "margin-left": {
136
+ "allowed": [
137
+ "px",
138
+ "em",
139
+ "fit-content",
140
+ "auto",
141
+ "%",
142
+ "inherit",
143
+ "-moz-fit-content",
144
+ "vh",
145
+ "0",
146
+ "initial",
147
+ "vw"
148
+ ],
149
+ "replacements": {
150
+ "px": "var(--zd_size$$)"
151
+ },
152
+ "range": {
153
+ "start": -1650,
154
+ "end": 1650
155
+ }
156
+ },
157
+ "margin-right": {
158
+ "allowed": [
159
+ "px",
160
+ "em",
161
+ "fit-content",
162
+ "auto",
163
+ "%",
164
+ "inherit",
165
+ "-moz-fit-content",
166
+ "vh",
167
+ "0",
168
+ "initial",
169
+ "vw"
170
+ ],
171
+ "replacements": {
172
+ "px": "var(--zd_size$$)"
173
+ },
174
+ "range": {
175
+ "start": -1650,
176
+ "end": 1650
177
+ }
178
+ },
179
+ "margin-top": {
180
+ "allowed": [
181
+ "px",
182
+ "em",
183
+ "fit-content",
184
+ "auto",
185
+ "%",
186
+ "inherit",
187
+ "-moz-fit-content",
188
+ "vh",
189
+ "0",
190
+ "initial",
191
+ "vw"
192
+ ],
193
+ "replacements": {
194
+ "px": "var(--zd_size$$)"
195
+ },
196
+ "range": {
197
+ "start": -1650,
198
+ "end": 1650
199
+ }
200
+ },
201
+ "margin-bottom": {
202
+ "allowed": [
203
+ "px",
204
+ "em",
205
+ "fit-content",
206
+ "auto",
207
+ "%",
208
+ "inherit",
209
+ "-moz-fit-content",
210
+ "vh",
211
+ "0",
212
+ "initial",
213
+ "vw"
214
+ ],
215
+ "replacements": {
216
+ "px": "var(--zd_size$$)"
217
+ },
218
+ "range": {
219
+ "start": -1650,
220
+ "end": 1650
221
+ }
222
+ },
223
+ "padding": {
224
+ "allowed": [
225
+ "px",
226
+ "em",
227
+ "fit-content",
228
+ "auto",
229
+ "%",
230
+ "inherit",
231
+ "-moz-fit-content",
232
+ "vh",
233
+ "0",
234
+ "initial",
235
+ "vw"
236
+ ],
237
+ "replacements": {
238
+ "px": "var(--zd_size$$)"
239
+ },
240
+ "range": {
241
+ "start": -1650,
242
+ "end": 1650
243
+ }
244
+ },
245
+ "padding-left": {
246
+ "allowed": [
247
+ "px",
248
+ "em",
249
+ "fit-content",
250
+ "auto",
251
+ "%",
252
+ "inherit",
253
+ "-moz-fit-content",
254
+ "vh",
255
+ "0",
256
+ "initial",
257
+ "vw"
258
+ ],
259
+ "replacements": {
260
+ "px": "var(--zd_size$$)"
261
+ },
262
+ "range": {
263
+ "start": -1650,
264
+ "end": 1650
265
+ }
266
+ },
267
+ "padding-right": {
268
+ "allowed": [
269
+ "px",
270
+ "em",
271
+ "fit-content",
272
+ "auto",
273
+ "%",
274
+ "inherit",
275
+ "-moz-fit-content",
276
+ "vh",
277
+ "0",
278
+ "initial",
279
+ "vw"
280
+ ],
281
+ "replacements": {
282
+ "px": "var(--zd_size$$)"
283
+ },
284
+ "range": {
285
+ "start": -1650,
286
+ "end": 1650
287
+ }
288
+ },
289
+ "padding-top": {
290
+ "allowed": [
291
+ "px",
292
+ "em",
293
+ "fit-content",
294
+ "auto",
295
+ "%",
296
+ "inherit",
297
+ "-moz-fit-content",
298
+ "vh",
299
+ "0",
300
+ "initial",
301
+ "vw"
302
+ ],
303
+ "replacements": {
304
+ "px": "var(--zd_size$$)"
305
+ },
306
+ "range": {
307
+ "start": -1650,
308
+ "end": 1650
309
+ }
310
+ },
311
+ "padding-bottom": {
312
+ "allowed": [
313
+ "px",
314
+ "em",
315
+ "fit-content",
316
+ "auto",
317
+ "%",
318
+ "inherit",
319
+ "-moz-fit-content",
320
+ "vh",
321
+ "0",
322
+ "initial",
323
+ "vw"
324
+ ],
325
+ "replacements": {
326
+ "px": "var(--zd_size$$)"
327
+ },
328
+ "range": {
329
+ "start": -1650,
330
+ "end": 1650
331
+ }
332
+ },
333
+ "height": {
334
+ "allowed": [
335
+ "px",
336
+ "em",
337
+ "fit-content",
338
+ "auto",
339
+ "%",
340
+ "inherit",
341
+ "-moz-fit-content",
342
+ "vh",
343
+ "0",
344
+ "initial",
345
+ "vw"
346
+ ],
347
+ "replacements": {
348
+ "px": "var(--zd_size$$)"
349
+ },
350
+ "range": {
351
+ "start": -1650,
352
+ "end": 1650
353
+ }
354
+ },
355
+ "width": {
356
+ "allowed": [
357
+ "px",
358
+ "em",
359
+ "fit-content",
360
+ "auto",
361
+ "%",
362
+ "inherit",
363
+ "-moz-fit-content",
364
+ "vh",
365
+ "0",
366
+ "initial",
367
+ "vw"
368
+ ],
369
+ "replacements": {
370
+ "px": "var(--zd_size$$)"
371
+ },
372
+ "range": {
373
+ "start": -1650,
374
+ "end": 1650
375
+ }
376
+ },
377
+ "min-width": {
378
+ "allowed": [
379
+ "px",
380
+ "em",
381
+ "fit-content",
382
+ "auto",
383
+ "%",
384
+ "inherit",
385
+ "-moz-fit-content",
386
+ "vh",
387
+ "0",
388
+ "initial",
389
+ "vw"
390
+ ],
391
+ "replacements": {
392
+ "px": "var(--zd_size$$)"
393
+ },
394
+ "range": {
395
+ "start": -1650,
396
+ "end": 1650
397
+ }
398
+ },
399
+ "max-width": {
400
+ "allowed": [
401
+ "px",
402
+ "em",
403
+ "fit-content",
404
+ "auto",
405
+ "%",
406
+ "inherit",
407
+ "-moz-fit-content",
408
+ "vh",
409
+ "0",
410
+ "initial",
411
+ "vw"
412
+ ],
413
+ "replacements": {
414
+ "px": "var(--zd_size$$)"
415
+ },
416
+ "range": {
417
+ "start": -1650,
418
+ "end": 1650
419
+ }
420
+ },
421
+ "min-height": {
422
+ "allowed": [
423
+ "px",
424
+ "em",
425
+ "fit-content",
426
+ "auto",
427
+ "%",
428
+ "inherit",
429
+ "-moz-fit-content",
430
+ "vh",
431
+ "0",
432
+ "initial",
433
+ "vw"
434
+ ],
435
+ "replacements": {
436
+ "px": "var(--zd_size$$)"
437
+ },
438
+ "range": {
439
+ "start": -1650,
440
+ "end": 1650
441
+ }
442
+ },
443
+ "max-height": {
444
+ "allowed": [
445
+ "px",
446
+ "em",
447
+ "fit-content",
448
+ "auto",
449
+ "%",
450
+ "inherit",
451
+ "-moz-fit-content",
452
+ "vh",
453
+ "0",
454
+ "initial",
455
+ "vw"
456
+ ],
457
+ "replacements": {
458
+ "px": "var(--zd_size$$)"
459
+ },
460
+ "range": {
461
+ "start": -1650,
462
+ "end": 1650
463
+ }
464
+ },
465
+ "top": {
466
+ "allowed": [
467
+ "px",
468
+ "em",
469
+ "fit-content",
470
+ "auto",
471
+ "%",
472
+ "inherit",
473
+ "-moz-fit-content",
474
+ "vh",
475
+ "0",
476
+ "initial",
477
+ "vw"
478
+ ],
479
+ "replacements": {
480
+ "px": "var(--zd_size$$)"
481
+ },
482
+ "range": {
483
+ "start": -1650,
484
+ "end": 1650
485
+ }
486
+ },
487
+ "bottom": {
488
+ "allowed": [
489
+ "px",
490
+ "em",
491
+ "fit-content",
492
+ "auto",
493
+ "%",
494
+ "inherit",
495
+ "-moz-fit-content",
496
+ "vh",
497
+ "0",
498
+ "initial",
499
+ "vw"
500
+ ],
501
+ "replacements": {
502
+ "px": "var(--zd_size$$)"
503
+ },
504
+ "range": {
505
+ "start": -1650,
506
+ "end": 1650
507
+ }
508
+ },
509
+ "left": {
510
+ "allowed": [
511
+ "px",
512
+ "em",
513
+ "fit-content",
514
+ "auto",
515
+ "%",
516
+ "inherit",
517
+ "-moz-fit-content",
518
+ "vh",
519
+ "0",
520
+ "initial",
521
+ "vw"
522
+ ],
523
+ "replacements": {
524
+ "px": "var(--zd_size$$)"
525
+ },
526
+ "range": {
527
+ "start": -1650,
528
+ "end": 1650
529
+ }
530
+ },
531
+ "right": {
532
+ "allowed": [
533
+ "px",
534
+ "em",
535
+ "fit-content",
536
+ "auto",
537
+ "%",
538
+ "inherit",
539
+ "-moz-fit-content",
540
+ "vh",
541
+ "0",
542
+ "initial",
543
+ "vw"
544
+ ],
545
+ "replacements": {
546
+ "px": "var(--zd_size$$)"
547
+ },
548
+ "range": {
549
+ "start": -1650,
550
+ "end": 1650
551
+ }
552
+ }
553
+ }
554
+ }
555
+ ```
556
+
557
+ Step 1 : Adding variable:ignore
558
+
559
+ use command `npm run variable:addignore` on source folder
560
+
561
+ before :
562
+ ```css
563
+ .a{
564
+ font-size: var(--zd_size14);
565
+ margin: var(--zd_size12);
566
+ padding: 12px;
567
+ }
568
+ ```
569
+
570
+ after :
571
+
572
+ ```css
573
+ /* explanation : since padding has declaration in px instead of var, it is considered unique and thereby no conversion should take place, hence we add variable:ignore preceding the line */
574
+ .a{
575
+ font-size: var(--zd_size14);
576
+ margin: var(--zd_size12);
577
+ /*Variable:Ignore*/
578
+ padding: 12px;
579
+ }
580
+ ```
581
+
582
+ Step 2 : Converting vars to px
583
+
584
+ use command `npm run variable:convert` on source folder
585
+
586
+ before :
587
+ ```css
588
+ .a{
589
+ font-size: var(--zd_size14);
590
+ margin: var(--zd_size12);
591
+ /*Variable:Ignore*/
592
+ padding: 12px;
593
+ }
594
+ ```
595
+
596
+ after :
597
+ ```css
598
+ /* explanation : conversion from vars to px is done making the declarations convertable to custom variables further by the react-cli plugin*/
599
+ .a{
600
+ font-size: 14px;
601
+ margin: 12px;
602
+ /*Variable:Ignore*/
603
+ padding: 12px;
604
+ }
605
+ ```
606
+
607
+ Step 3 : Conversion from px to custom variables present in settings
608
+
609
+ Things that are considered in the conversion :
610
+ => `allowed` is the allowed units that can be converted through the plugin
611
+ => `replacements` are the conversion strings where `$$` will be converted to respective numbers
612
+ => `range` is the starting and ending value within numbers will be allowed.
613
+
614
+ `variableModificationPlugin` in react-cli folder is where the conversion takes place.
615
+
616
+ and output would be as follows :
617
+
618
+ before :
619
+
620
+ ```css
621
+ /* explanation : conversion from px to variable is allowed since, all the conditions for font-size and margin are satisfied, the numbers are within range and the unit is in the allowed array, replacements are thereby taken from the values in replacements and conversion is done to custom variables */
622
+
623
+ /*
624
+ "font-size": {
625
+ "allowed": [
626
+ "px",
627
+ "em",
628
+ "%",
629
+ "0",
630
+ "vh",
631
+ "initial"
632
+ ],
633
+ "replacements": {
634
+ "px": "var(--zd_font_size$$)",
635
+ "em": "var(--zd_font_size$$em)"
636
+ },
637
+ "range": {
638
+ "start": 0,
639
+ "end": 1650
640
+ }
641
+ },
642
+ */
643
+ /*
644
+
645
+ "margin": {
646
+ "allowed": [
647
+ "px",
648
+ "em",
649
+ "fit-content",
650
+ "auto",
651
+ "%",
652
+ "inherit",
653
+ "-moz-fit-content",
654
+ "vh",
655
+ "0",
656
+ "initial",
657
+ "vw"
658
+ ],
659
+ "replacements": {
660
+ "px": "var(--zd_size$$)"
661
+ },
662
+ "range": {
663
+ "start": -1650,
664
+ "end": 1650
665
+ }
666
+ },
667
+
668
+ */
669
+ .a{
670
+ font-size: 14px;
671
+ margin: 12px;
672
+ /*Variable:Ignore*/
673
+ padding: 12px;
674
+ }
675
+ ```
676
+
677
+ after :
678
+
679
+ ```css
680
+
681
+ .a{
682
+ font-size: var(--zd_size14);
683
+ margin: var(--zd_size12);
684
+ /*Variable:Ignore*/
685
+ padding: 12px;
686
+ }
687
+ ```
688
+
689
+ Output configuration :
690
+
691
+ Consider the below mentioned :
692
+ ```json
693
+ "errorLog": false,
694
+ "errorInConsole": false,
695
+ "errorsAllowed":{
696
+ "DECLARATION_IGNORED" : true,
697
+ "UNIT_ERROR" : true,
698
+ "RANGE_ERROR" : true,
699
+ "DECIMAL_CHECK":true,
700
+ "DECIMAL_REJECT":true,
701
+ "VARIABLE_PRESENT" : true
702
+ },
703
+ ```
704
+ . if an error log is necessary, a physical file `css_error.log` will be created in the source directory upon making `errorLog` true. will take generally more than usual time to write in the file, so delay in build is present.
705
+
706
+ . if error is needed to be seen in the console, `errorInConsole` should be enabled, all errors will be printed in the console.
707
+
708
+ . Individual errors can be enabled in `errorsAllowed` to collaboratively produce the error log file / errors in console. Here each of the errors mean the following :
709
+
710
+ => `DECLARATION_IGNORED` : Lines that succeed the /*Variable:Ignore*/ comment.
711
+ => `UNIT_ERROR` : the units that are not present in the corresponding property's `allowed` array are used.
712
+ => `RANGE_ERROR` : numerical values that are not present within the range of the corresponding property's `range` is used.
713
+ => `DECIMAL_CHECK` : Decimal values containing . will be shown ( flex : 1.3 )
714
+ => `DECIMAL_REJECT` : Decimal values such as .em which are to be rejected are shown ( font-size : 12.5px )
715
+ => `VARIABLE_PRESENT` : conversion to px (Step 2) wasn't done properly and hence there are residues that contain `var` in it are found.
716
+ => `MULTIPLE_OCCURANCES` : using --vars in multiple places ( using --zd_avatar_padding_left in left and right ), which results in confusion during conversion
717
+
718
+ * First two conversions are to be done manually by the use of the commands, `npm run variable:addignore` and `npm run variable:convert`
719
+ * Final conversion is done by react-cli on compilation of the source folder `npm run start --app:port=**** --app:domain=****`