@zohodesk/react-cli 1.0.3 → 1.1.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 (42) hide show
  1. package/README.md +26 -1
  2. package/bin/cli.js +18 -4
  3. package/docs/ComposeMinification.md +13 -0
  4. package/docs/ReactLive.md +10 -0
  5. package/docs/patternFiltering.md +57 -0
  6. package/lib/common/buildEs.js +12 -0
  7. package/lib/configs/webpack.dev.config.js +3 -0
  8. package/lib/configs/webpack.docs.config.js +8 -1
  9. package/lib/configs/webpack.impact.config.js +2 -0
  10. package/lib/configs/webpack.prod.config.js +3 -0
  11. package/lib/loaderUtils/getCSSLoaders.js +77 -46
  12. package/lib/loaderUtils/tests/windowsModification.test.js +10 -0
  13. package/lib/loaderUtils/windowsModification.js +6 -1
  14. package/lib/loaders/composeLoader.js +172 -0
  15. package/lib/loaders/docsLoader.js +15 -7
  16. package/lib/loaders/reactLiveConvertor.js +105 -0
  17. package/lib/pluginUtils/getDevPlugins.js +10 -3
  18. package/lib/pluginUtils/getProdPlugins.js +8 -3
  19. package/lib/pluginUtils/getUMDCSSPlugins.js +1 -1
  20. package/lib/pluginUtils/getUMDComponentPlugins.js +1 -1
  21. package/lib/plugins/{UglifyCSSPlugin.js → MinifyPlugin.js} +3 -3
  22. package/lib/plugins/SelectorPlugin.js +63 -40
  23. package/lib/plugins/VariableConversionCollector.js +40 -97
  24. package/lib/plugins/index.js +7 -7
  25. package/lib/plugins/utils/classHandling.js +35 -0
  26. package/lib/plugins/utils/fileHandling.js +107 -0
  27. package/lib/plugins/utils/tests/fileHandling.test.js +30 -0
  28. package/lib/plugins/variableConvertorUtils.js +131 -0
  29. package/lib/postcss-plugins/EmptyPlugin.js +8 -0
  30. package/lib/postcss-plugins/ExcludePlugin.js +1 -1
  31. package/lib/postcss-plugins/ValueReplacer.js +5 -14
  32. package/lib/postcss-plugins/variableModificationPlugin/index.js +2 -19
  33. package/lib/schemas/index.js +75 -4
  34. package/lib/servers/server.js +2 -2
  35. package/lib/utils/cssClassNameGenerate.js +34 -9
  36. package/lib/utils/getOptions.js +45 -0
  37. package/lib/utils/selectorReplacer.js +47 -0
  38. package/lib/utils/variableConverter.js +89 -0
  39. package/{package-lock.json → npm-shrinkwrap.json} +79 -74
  40. package/package.json +3 -1
  41. package/lib/plugins/composeCommonPlugin.js +0 -30
  42. package/lib/postcss-plugins/variableModifier.js +0 -210
@@ -2,21 +2,29 @@
2
2
 
3
3
  var _fs = _interopRequireDefault(require("fs"));
4
4
 
5
+ var _getOptions = _interopRequireDefault(require("../utils/getOptions.js"));
6
+
5
7
  var _path = _interopRequireDefault(require("path"));
6
8
 
9
+ var _ReactLiveConvertor = require("./ReactLiveConvertor");
10
+
7
11
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
8
12
 
9
13
  module.exports = function (source) {
10
- let comNameAry = this.resourcePath.split(_path.default.sep);
11
- let filePath = this.resourcePath;
14
+ const comNameAry = this.resourcePath.split(_path.default.sep);
15
+ const filePath = this.resourcePath;
16
+
17
+ const appPath = _fs.default.realpathSync(process.cwd());
12
18
 
13
- let appPath = _fs.default.realpathSync(process.cwd());
19
+ const changePath = filePath.replace('/lib/', '/src/');
20
+ const comName = comNameAry[comNameAry.length - 1];
21
+ const name = comName.substring(0, comName.lastIndexOf('.'));
22
+ const options = (0, _getOptions.default)();
23
+ const originalFilePath = filePath.startsWith(appPath) ? filePath : changePath;
14
24
 
15
- let changePath = filePath.replace('/lib/', '/src/');
16
- let comName = comNameAry[comNameAry.length - 1];
17
- let name = comName.substring(0, comName.lastIndexOf('.'));
25
+ const src = _fs.default.readFileSync(originalFilePath).toString();
18
26
 
19
- let src = _fs.default.readFileSync(filePath.startsWith(appPath) ? filePath : changePath).toString();
27
+ options.docs.enableReactLive && (source = (0, _ReactLiveConvertor.reactLiveConvertor)(source, originalFilePath)); //to Enable the ReactLive Converter
20
28
 
21
29
  return `${source};${name}.source=${JSON.stringify(src)};${name}.filePath=${JSON.stringify(filePath)}`;
22
30
  };
@@ -0,0 +1,105 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.reactLiveConvertor = reactLiveConvertor;
7
+
8
+ const parser = require('@babel/parser');
9
+
10
+ const traverse = require('@babel/traverse').default;
11
+
12
+ const path = require('path');
13
+
14
+ function getFilename(originalFilePath) {
15
+ const [fileName] = path.basename(originalFilePath).split('.');
16
+ return fileName;
17
+ }
18
+
19
+ function reactLiveConvertor(source, originalFilePath) {
20
+ const fileName = getFilename(originalFilePath);
21
+
22
+ if (!source) {
23
+ return '';
24
+ }
25
+
26
+ let importBlock = '';
27
+ let docCode = '';
28
+ const packages = new Set();
29
+ const fileContent = source.replace(/[\s\r\n]*$/, '');
30
+ const ast = parser.parse(fileContent, {
31
+ sourceType: 'module',
32
+ plugins: ['jsx', 'classProperties']
33
+ }); // Traverse the AST and find the import and export blocks
34
+
35
+ let remainingCode = ast.program.body.filter(node => node.type !== 'ImportDeclaration').map(node => fileContent.substring(node.start, node.end)).join('').replace(/export default/, '').replace(/export /, '').trim();
36
+ traverse(ast, {
37
+ ImportDeclaration(path) {
38
+ importBlock += `${fileContent.slice(path.node.start, path.node.end)}\n`;
39
+ path.node.specifiers.forEach(specifier => {
40
+ if (specifier.type === 'ImportSpecifier') {
41
+ packages.add(specifier.imported.name);
42
+ }
43
+
44
+ if (specifier.local.type === 'Identifier') {
45
+ packages.add(specifier.local.name);
46
+ }
47
+ });
48
+ },
49
+
50
+ ExpressionStatement(path) {
51
+ const expression = path.get('expression');
52
+ const expressionLeft = expression.get('left');
53
+
54
+ if (path.isExpressionStatement() && expression.isAssignmentExpression() && expressionLeft.isMemberExpression()) {
55
+ const docCheck = expressionLeft.toString();
56
+
57
+ if (docCheck === `${fileName}.docs`) {
58
+ docCode = expression.toString();
59
+ }
60
+ }
61
+ } // IfStatement(path){
62
+ // if(path.node.type == 'IfStatement'){
63
+ // if(path.node.test.name == '__DOCS__'){
64
+ // let final = fileContent.slice(path.node.start,path.node.end)
65
+ // fileContent = fileContent.replace(final,'')
66
+ // console.log(fileContent);
67
+ // }
68
+ // }
69
+ // }
70
+
71
+
72
+ });
73
+ remainingCode = remainingCode.replace(/__DOCS__/, true);
74
+ remainingCode = remainingCode.replace(/`/g, '\\`').replace(/\$\{/g, '$\\{');
75
+ const brcklets = `(function () {
76
+
77
+ ${remainingCode}
78
+
79
+ return <${fileName} />
80
+
81
+ }) ()`;
82
+ const addBractick = `\`${brcklets}\``;
83
+ const template = `
84
+
85
+ ${importBlock}
86
+
87
+ import { LiveProvider, LiveEditor, LiveError, LivePreview } from '@zohodesk-private/react-live/es/index'
88
+
89
+ export default class ${fileName} extends React.Component{
90
+ render(){
91
+ return(
92
+ <LiveProvider scope={{${Array.from(packages).join(', ')}}} code={${addBractick}}>
93
+ <LiveEditor />
94
+ <LiveError />
95
+ <LivePreview />
96
+
97
+ </LiveProvider>
98
+ )
99
+ }
100
+ }
101
+
102
+ ${docCode}
103
+ `;
104
+ return template;
105
+ }
@@ -51,6 +51,7 @@ const getDevPlugins = (options, publicPath) => {
51
51
  hasShadowDOM,
52
52
  cssVariableReplacementConfig,
53
53
  plugins: pluginObject,
54
+ patterns,
54
55
  exclude,
55
56
  selectorWeightConfig,
56
57
  server: {
@@ -199,16 +200,22 @@ const getDevPlugins = (options, publicPath) => {
199
200
 
200
201
  if (pluginObject.cssVariableReplacement) {
201
202
  pluginsArr.push(new _VariableConversionCollector.default({
202
- cssVariableReplacementConfig
203
+ cssVariableReplacementConfig,
204
+ patterns
203
205
  }));
204
206
  }
205
207
 
206
208
  if (pluginObject.selectorWeight) {
207
209
  pluginsArr.push(new _SelectorPlugin.default({
208
210
  selectorWeightConfig,
209
- exclude: exclude.selectorWeight
211
+ exclude: exclude.selectorWeight,
212
+ patterns
210
213
  }));
211
- }
214
+ } // if (pluginObject.minifier) {
215
+ // // console.log('minifier active');
216
+ // pluginsArr.push(new MinifierPlugin());
217
+ // }
218
+
212
219
 
213
220
  return pluginsArr.filter(Boolean);
214
221
  };
@@ -47,12 +47,14 @@ const getProdPlugins = (options, publicPath = '') => {
47
47
  bundleAnalyze,
48
48
  optimize,
49
49
  publicPaths,
50
+ patterns,
50
51
  hasEFC: prevOptionForEnableEFC,
51
52
  enableSMapHook,
52
53
  tpFolder,
53
54
  folder,
54
55
  outputFolder,
55
56
  context,
57
+ exclude,
56
58
  enableSMap,
57
59
  server: {
58
60
  mode
@@ -105,7 +107,7 @@ const getProdPlugins = (options, publicPath = '') => {
105
107
  // ignoreOrder: true,
106
108
  filename: cssLTRFileNameTempalte,
107
109
  chunkFilename: cssLTRFileNameTempalte
108
- }), new _plugins.ResourceHintsPlugin(), new _plugins.UglifyCSSPlugin()];
110
+ }), new _plugins.ResourceHintsPlugin(), new _plugins.MinifyPlugin()];
109
111
 
110
112
  if (enableRTLSplit) {
111
113
  pluginsArr.push(new _RtlCssPlugin.RtlCssPlugin({
@@ -271,13 +273,16 @@ const getProdPlugins = (options, publicPath = '') => {
271
273
 
272
274
  if (pluginObject.cssVariableReplacement) {
273
275
  pluginsArr.push(new _VariableConversionCollector.default({
274
- cssVariableReplacementConfig
276
+ cssVariableReplacementConfig,
277
+ patterns
275
278
  }));
276
279
  }
277
280
 
278
281
  if (pluginObject.selectorWeight) {
279
282
  pluginsArr.push(new _SelectorPlugin.default({
280
- selectorWeightConfig
283
+ selectorWeightConfig,
284
+ exclude: exclude.selectorWeight,
285
+ patterns
281
286
  }));
282
287
  } // plugins.push(new VariableConversionCollector({}));
283
288
 
@@ -27,7 +27,7 @@ let getUMDCSSPlugins = () => {
27
27
  }), new _miniCssExtractPlugin.default({
28
28
  filename: 'css/[name].css',
29
29
  chunkFilename: 'css/[id].css'
30
- }), new _plugins.UglifyCSSPlugin()];
30
+ }), new _plugins.MinifyPlugin()];
31
31
  return plugins;
32
32
  };
33
33
 
@@ -27,7 +27,7 @@ let getUMDComponentPlugins = isDocs => {
27
27
  }), new _miniCssExtractPlugin.default({
28
28
  filename: 'css/[name].css',
29
29
  chunkFilename: 'css/[name].css'
30
- }), new _plugins.UglifyCSSPlugin()];
30
+ }), new _plugins.MinifyPlugin()];
31
31
  return plugins;
32
32
  };
33
33
 
@@ -11,9 +11,9 @@ var _uglifycss = _interopRequireDefault(require("uglifycss"));
11
11
 
12
12
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
13
13
 
14
- class UglifyCSSPlugin {
14
+ class MinifierPlugin {
15
15
  apply(compiler) {
16
- compiler.hooks.emit.tap('UglifyCSSPlugin', compilation => {
16
+ compiler.hooks.emit.tap('MinifierPlugin', compilation => {
17
17
  Object.keys(compilation.assets).forEach(filename => {
18
18
  if (/\.css$/.test(filename)) {
19
19
  try {
@@ -36,4 +36,4 @@ class UglifyCSSPlugin {
36
36
 
37
37
  }
38
38
 
39
- exports.default = UglifyCSSPlugin;
39
+ exports.default = MinifierPlugin;
@@ -9,72 +9,63 @@ 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
- const prevNode = rootOriginal.nodes[index - 1];
22
+ const prevNode = rootOriginal.nodes[index - 1] || null;
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
+ } // console.log(rule.selector.split(','));
33
27
 
34
- if (rule.parent && rule.parent.type === 'atrule') {
35
- if (rule.parent.name !== 'media') {
36
- return;
37
- }
38
- }
39
28
 
40
29
  const selectorArr = rule.selector.split(',');
41
30
  selectorArr.forEach((singleSelectorStr, index) => {
42
31
  if (excludeStrings.includes(singleSelectorStr.trim())) {
43
32
  return;
44
- }
33
+ } // NOTE: below logic for attrbute related
34
+
45
35
 
46
36
  if (singleSelectorStr.includes(']')) {
47
- if (singleSelectorStr.slice(singleSelectorStr.lastIndexOf(']') + 2).trim() === '') {
37
+ // console.log(singleSelectorStr);
38
+ const prefixPart = singleSelectorStr.slice(0, singleSelectorStr.lastIndexOf(']') + 1).trim();
39
+ const selectorPart = singleSelectorStr.slice(singleSelectorStr.lastIndexOf(']') + 1).trim();
40
+
41
+ if (excludeStrings.includes(selectorPart.trim())) {
48
42
  return;
49
43
  }
50
44
 
51
- selectorArr[index] = `${singleSelectorStr.slice(0, singleSelectorStr.lastIndexOf(']') + 1).trim()} ${defaultSelector}${singleSelectorStr.slice(singleSelectorStr.lastIndexOf(']') + 2).trim()}`;
45
+ if (/^:/gi.test(selectorPart)) {
46
+ return;
47
+ }
48
+
49
+ if (selectorPart !== '') {
50
+ selectorArr[index] = `${prefixPart} ${selector}${selectorPart}`;
51
+ }
52
+
52
53
  return;
53
54
  }
54
55
 
55
- const keyMatch = checkFilename(filename, data);
56
- selectorArr[index] = data[keyMatch] ? `${data[keyMatch].defaultSelector}${singleSelectorStr}` : `${defaultSelector}${singleSelectorStr}`;
56
+ selectorArr[index] = `${selector}${singleSelectorStr}`;
57
57
  });
58
58
  rule.selector = selectorArr.join(',\n');
59
59
  });
60
60
  return rootOriginal;
61
61
  }
62
62
 
63
- function ignoreFile(excludeArr, filename) {
64
- let ignore = false;
65
- excludeArr.forEach(exclStr => {
66
- if (filename.includes(exclStr)) {
67
- ignore = true;
68
- }
69
- });
70
- return ignore;
71
- }
72
-
73
63
  class SelectorPlugin {
74
64
  constructor(options = {}) {
75
65
  this.optimize = options.optimize;
76
66
  this.selectorWeightConfig = options.selectorWeightConfig;
77
67
  this.exclude = options.exclude;
68
+ this.patterns = options.patterns;
78
69
  }
79
70
 
80
71
  apply(compiler) {
@@ -94,15 +85,47 @@ class SelectorPlugin {
94
85
  mods.forEach(module => {
95
86
  const rootOriginal = _postcss.default.parse(module.content);
96
87
 
97
- const filename = module.issuer.resource; // if (!filename.includes('node_modules')) {
98
-
99
- if (ignoreFile(this.exclude, filename)) {
88
+ const filename = module.issuer.resource;
89
+ /*
90
+ input :
91
+ filename : 'D:/MyWork/..../desk_client_app/supportapp/src/components/Avatar/Avatar.module.css,
92
+
93
+ patterns.cssVariableReplacement:
94
+ // include src folder, include deskapp folder, exclude node modules
95
+ "selectorWeight": [
96
+ "src",
97
+ "deskapp",
98
+ "!node_modules"
99
+ ]
100
+
101
+ output :
102
+ true or false
103
+ */
104
+
105
+ if (!(0, _fileHandling.isFileNameMatchingPluginPattern)({
106
+ filename,
107
+ filterArr: this.patterns.selectorWeight
108
+ })) {
100
109
  return;
101
110
  }
111
+ /*
112
+
113
+ filename : Deskapp.module.css ?
114
+ data :
115
+ {
116
+ "DeskApp.module.css": {"defaultSelector" : ".desk_app_ui "}
117
+ }
118
+ selectorWeightConfig :
119
+ defaultSelector : .zoho_desk_ui
120
+
121
+ case filename = 'DeskApp.module.css' ?
122
+ data[filename].defaultSelector = '.desk_app_ui'
123
+ case filename is different ?
124
+ defaultSelector = '.zoho_desk_ui'
125
+ */
126
+
102
127
 
103
- module.content = //new RawSource(
104
- rootConvertor(rootOriginal, defaultSelector, data, filename, excludeStrings).toString(); // );
105
- // }
128
+ module.content = selectorWeightPrefixAdder(rootOriginal, data[filename] ? data[filename].defaultSelector : defaultSelector, excludeStrings).toString();
106
129
  });
107
130
  });
108
131
  });
@@ -9,12 +9,15 @@ 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
+
14
+ var _variableConvertorUtils = require("./variableConvertorUtils");
15
+
12
16
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
13
17
 
14
18
  // import { RawSource } from 'webpack-sources';
15
19
  const fs = require('fs');
16
20
 
17
- const ignoreVals = ['--zd_size', '--zd_font_size', '--size', '--size_'];
18
21
  let variablesRead = {};
19
22
 
20
23
  const {
@@ -23,29 +26,7 @@ const {
23
26
  errHandler
24
27
  } = require('../postcss-plugins/variableModificationPlugin/index');
25
28
 
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
- // -- is issue IO --
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
38
- */
39
-
40
- function isIgnoreValuePresent(ignoreVals, prop) {
41
- let present = false;
42
- ignoreVals.forEach(issue => {
43
- if (prop && prop.includes(issue)) {
44
- present = true;
45
- }
46
- });
47
- return present;
48
- } // -- to convert the hyphen values to values --
29
+ 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']; // -- to convert the hyphen values to values --
49
30
 
50
31
  /*
51
32
  input :
@@ -57,49 +38,6 @@ comment :
57
38
  to make the variable object using the output as key and decl.prop such as font-size as value
58
39
  */
59
40
 
60
-
61
- function extractVariableName(val) {
62
- return val.replace(/calc\((.+)\)/gi, '$1').replace(/var\((.+)\)/gi, '$1').replace('-1', '').replace('*', '').replace('\n', '').trim();
63
- }
64
-
65
- function rootConvertor(rootOriginal, variables, settingsObject) {
66
- rootOriginal.walkRules(rule => {
67
- rule.nodes.forEach((decl, index) => {
68
- const prevNode = rule.nodes[index - 1];
69
- const currentNode = rule.nodes[index];
70
-
71
- if (decl.prop && decl.prop.includes('--')) {
72
- if (prevNode && prevNode.type === 'comment' && prevNode.text.toLowerCase() === 'variable:ignore') {
73
- return;
74
- }
75
-
76
- if (isIgnoreValuePresent(ignoreVals, decl.prop)) {
77
- return;
78
- }
79
-
80
- if (settingsObject[variables[decl.prop]]) {
81
- /* if there is no value for property, set it to default so that undefined doesn't get called as key */
82
- if (!variables[decl.prop]) {
83
- variables[decl.prop] = 'default';
84
- }
85
-
86
- const pxReplacement = settingsObject[variables[decl.prop]].replacements.px;
87
- const valArr = decl.value.split(' '); // single values are considered in the above array and converted below
88
-
89
- valArr.forEach((value, index) => {
90
- if (value.includes('px')) {
91
- const num = value.replace('px', '');
92
- valArr[index] = pxReplacement.replace('$$', num);
93
- }
94
- });
95
- currentNode.value = valArr.join(' ');
96
- }
97
- }
98
- });
99
- });
100
- return rootOriginal;
101
- }
102
-
103
41
  function createFolderIfNonExistant(path) {
104
42
  if (!fs.existsSync(path)) {
105
43
  fs.mkdirSync(path, {
@@ -118,10 +56,12 @@ class VariableConversionCollector {
118
56
  constructor(options = {}) {
119
57
  this.optimize = options.optimize;
120
58
  this.filename = options.cssVariableReplacementConfig;
121
- this.fileHandler();
59
+ this.patterns = options.patterns; // console.log(options.patterns, this.patterns);
60
+
61
+ this.initializeFiles();
122
62
  }
123
63
 
124
- fileHandler() {
64
+ initializeFiles() {
125
65
  createFolderIfNonExistant('./.cli/logs/');
126
66
  createFolderIfNonExistant('./.cli/config/variables/');
127
67
  createFolderIfNonExistant('./.cli/config/selectorWeight/');
@@ -131,7 +71,8 @@ class VariableConversionCollector {
131
71
 
132
72
  apply(compiler) {
133
73
  const variables = {};
134
- const unassigned = {};
74
+ const unassigned = {}; // console.log(windowsModification([this.filename])[0]);
75
+
135
76
  const rawdata = fs.readFileSync(this.filename);
136
77
  const data = JSON.parse(rawdata);
137
78
  const {
@@ -183,8 +124,8 @@ class VariableConversionCollector {
183
124
  rootOriginal.walkRules(rule => {
184
125
  rule.walkDecls(decl => {
185
126
  decl.value.split(' ').forEach(val => {
186
- if (val && val.includes('--') && !new RegExp(ignoreVals.join('|'), 'gi').test(val) && decl.prop) {
187
- const extractedValue = extractVariableName(val);
127
+ if (val && val.includes('--') && !new RegExp(_variableConvertorUtils.ignoreVals.join('|'), 'gi').test(val) && decl.prop) {
128
+ const extractedValue = (0, _variableConvertorUtils.extractVariableName)(val);
188
129
 
189
130
  if (!variables[extractedValue]) {
190
131
  variables[extractedValue] = decl.prop;
@@ -234,7 +175,7 @@ class VariableConversionCollector {
234
175
  });
235
176
  }
236
177
  });
237
- }); // -- conversion for the root using rootConvertor --
178
+ }); // -- conversion for the root using variableConvertor --
238
179
 
239
180
  /*
240
181
  input :
@@ -252,9 +193,33 @@ class VariableConversionCollector {
252
193
  compilation.hooks.optimizeModules.tap('VariableConversionCollector', modules => {
253
194
  const mods = modules.filter(x => x.type.includes('css'));
254
195
  mods.forEach(module => {
196
+ const filename = module.issuer.resource;
197
+ /*
198
+ input :
199
+ filename : 'D:/MyWork/..../desk_client_app/supportapp/src/components/Avatar/Avatar.module.css,
200
+
201
+ patterns.cssVariableReplacement:
202
+ // include src folder, include deskapp folder, exclude node modules
203
+ "cssVariableReplacement": [
204
+ "src",
205
+ "deskapp",
206
+ "!node_modules"
207
+ ]
208
+
209
+ output :
210
+ true or false
211
+ */
212
+
213
+ if (!(0, _fileHandling.isFileNameMatchingPluginPattern)({
214
+ filename,
215
+ filterArr: this.patterns.cssVariableReplacement
216
+ })) {
217
+ return;
218
+ }
219
+
255
220
  const rootOriginal = _postcss.default.parse(module.content);
256
221
 
257
- module.content = rootConvertor(rootOriginal, variables, settingsObject).toString();
222
+ module.content = (0, _variableConvertorUtils.variableConverter)(rootOriginal, variables, settingsObject).toString();
258
223
  });
259
224
  });
260
225
  });
@@ -288,29 +253,7 @@ class VariableConversionCollector {
288
253
  if (a.type < b.type) {
289
254
  return -1;
290
255
  }
291
- }); // variable constructed now to be written in a json file
292
- // const newVars = Object.keys(variables)
293
- // //Filter Object with key contanis "NAME"
294
- // .filter(key => variables[key].includes('--'))
295
- // .reduce(
296
- // (obj, key) =>
297
- // Object.assign(obj, {
298
- // [key]: variables[key]
299
- // }),
300
- // {}
301
- // );
302
- // console.log('new variables: ', newVars);
303
- // try {
304
- // fs.writeFileSync('./variableMapping.json', JSON.stringify(variables));
305
- // } catch (err) {
306
- // console.log(err);
307
- // }
308
- // fs.writeFile('./variableMapping.json', JSON.stringify(variables), err => {
309
- // if (err) {
310
- // throw err;
311
- // }
312
- // console.log('variable mapping file generated.');
313
- // });
256
+ });
314
257
 
315
258
  if (errorConsoleStatus) {
316
259
  const errorHandler = new _ErrorHandler.ErrorHandler();
@@ -33,6 +33,12 @@ Object.defineProperty(exports, "ManifestPlugin", {
33
33
  return _ManifestPlugin.default;
34
34
  }
35
35
  });
36
+ Object.defineProperty(exports, "MinifyPlugin", {
37
+ enumerable: true,
38
+ get: function () {
39
+ return _MinifyPlugin.default;
40
+ }
41
+ });
36
42
  Object.defineProperty(exports, "ModuleStatsPlugin", {
37
43
  enumerable: true,
38
44
  get: function () {
@@ -99,12 +105,6 @@ Object.defineProperty(exports, "TPHashMappingPlugin", {
99
105
  return _TPHashMappingPlugin.default;
100
106
  }
101
107
  });
102
- Object.defineProperty(exports, "UglifyCSSPlugin", {
103
- enumerable: true,
104
- get: function () {
105
- return _UglifyCSSPlugin.default;
106
- }
107
- });
108
108
  Object.defineProperty(exports, "UnusedFilesFindPlugin", {
109
109
  enumerable: true,
110
110
  get: function () {
@@ -126,7 +126,7 @@ var _OptimizeJSPlugin = _interopRequireDefault(require("./OptimizeJSPlugin"));
126
126
 
127
127
  var _ResourceHintsPlugin = _interopRequireDefault(require("./ResourceHintsPlugin"));
128
128
 
129
- var _UglifyCSSPlugin = _interopRequireDefault(require("./UglifyCSSPlugin"));
129
+ var _MinifyPlugin = _interopRequireDefault(require("./MinifyPlugin"));
130
130
 
131
131
  var _ManifestPlugin = _interopRequireDefault(require("./ManifestPlugin"));
132
132