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

Sign up to get free protection for your applications and to get access to all the features.
Files changed (37) hide show
  1. package/README.md +13 -0
  2. package/docs/SelectorWeight.md +3 -0
  3. package/docs/VariableConversion.md +6 -1
  4. package/lib/configs/webpack.dev.config.js +6 -0
  5. package/lib/configs/webpack.docs.config.js +4 -0
  6. package/lib/configs/webpack.impact.config.js +4 -0
  7. package/lib/configs/webpack.prod.config.js +6 -0
  8. package/lib/loaderUtils/getCSSLoaders.js +79 -50
  9. package/lib/loaderUtils/tests/windowsModification.test.js +10 -0
  10. package/lib/loaderUtils/windowsModification.js +6 -1
  11. package/lib/loaders/composeLoader.js +175 -0
  12. package/lib/pluginUtils/getDevPlugins.js +13 -2
  13. package/lib/pluginUtils/getProdPlugins.js +1 -1
  14. package/lib/pluginUtils/getUMDCSSPlugins.js +1 -1
  15. package/lib/pluginUtils/getUMDComponentPlugins.js +1 -1
  16. package/lib/plugins/{UglifyCSSPlugin.js → MinifyPlugin.js} +3 -3
  17. package/lib/plugins/SelectorPlugin.js +60 -72
  18. package/lib/plugins/VariableConversionCollector.js +38 -29
  19. package/lib/plugins/index.js +15 -7
  20. package/lib/plugins/utils/classHandling.js +2 -10
  21. package/lib/plugins/utils/fileHandling.js +70 -100
  22. package/lib/plugins/utils/tests/fileHandling.test.js +30 -0
  23. package/lib/postcss-plugins/EmptyPlugin.js +8 -0
  24. package/lib/postcss-plugins/ExcludePlugin.js +1 -1
  25. package/lib/postcss-plugins/SelectorReplace.js +80 -0
  26. package/lib/postcss-plugins/ValueReplacer.js +2 -13
  27. package/lib/postcss-plugins/__test__/selectorReplace.test.js +28 -0
  28. package/lib/postcss-plugins/variableModificationPlugin/ErrorHandler.js +0 -1
  29. package/lib/postcss-plugins/variableModificationPlugin/index.js +14 -32
  30. package/lib/postcss-plugins/variableModifier.js +1 -1
  31. package/lib/schemas/index.js +34 -3
  32. package/lib/servers/server.js +2 -2
  33. package/lib/utils/cssClassNameGenerate.js +35 -7
  34. package/package.json +3 -2
  35. package/lib/plugins/composeCommonPlugin.js +0 -30
  36. package/lib/plugins/cssoPlugin.js +0 -37
  37. package/lib/plugins/utils/checkPattern.js +0 -57
@@ -9,77 +9,55 @@ var _postcss = _interopRequireDefault(require("postcss"));
9
9
 
10
10
  var _fs = _interopRequireDefault(require("fs"));
11
11
 
12
+ var _classHandling = require("./utils/classHandling");
13
+
14
+ var _fileHandling = require("./utils/fileHandling");
15
+
12
16
  var _windowsModification = require("../loaderUtils/windowsModification");
13
17
 
14
18
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
15
19
 
16
- function checkFilename(filename, data) {
17
- let keyMatch = undefined;
18
- Object.keys(data).forEach(key => {
19
- if (filename.includes(key)) {
20
- keyMatch = key;
21
- }
22
- });
23
- return keyMatch;
24
- }
25
-
26
- function rootConvertor(rootOriginal, defaultSelector, data, filename, excludeStrings) {
20
+ function selectorWeightPrefixAdder(rootOriginal, selector, excludeStrings) {
27
21
  rootOriginal.walkRules((rule, index) => {
28
22
  const prevNode = rootOriginal.nodes[index - 1];
29
23
 
30
- if (index !== 0 && prevNode.type && prevNode.type === 'comment' && prevNode.text.toLowerCase() === 'updateselector:ignore') {
24
+ if ((0, _classHandling.hasPrevNodeIgnore)(index, prevNode, 'updateselector:ignore')) {
31
25
  return;
32
26
  }
33
27
 
34
- if (rule.parent && rule.parent.type === 'atrule') {
35
- if (rule.parent.name !== 'media') {
36
- return;
37
- }
28
+ if (!(0, _classHandling.isInsideMediaQuery)(rule)) {
29
+ return;
38
30
  }
39
31
 
40
- let ruleArr = rule.selector.split(',');
41
- ruleArr.forEach((ruleStr, index) => {
42
- if (excludeStrings.includes(ruleStr.trim())) {
32
+ const selectorArr = rule.selector.split(',');
33
+ selectorArr.forEach((singleSelectorStr, index) => {
34
+ if (excludeStrings.includes(singleSelectorStr.trim())) {
43
35
  return;
44
36
  }
45
37
 
46
- if (ruleStr.includes(']')) {
47
- if (ruleStr.slice(ruleStr.lastIndexOf(']') + 2).trim() === '') {
38
+ if (singleSelectorStr.includes(']')) {
39
+ if (singleSelectorStr.slice(singleSelectorStr.lastIndexOf(']') + 2).trim() === '') {
48
40
  return;
49
- } // console.log(
50
- // rule.slice(rule.lastIndexOf(']') + 2).trim(),
51
- // rule.slice(rule.lastIndexOf(']') + 2).trim() !== ''
52
- // );
53
-
54
-
55
- ruleArr[index] = `${ruleStr.slice(0, ruleStr.lastIndexOf(']') + 1).trim()} ${defaultSelector}${ruleStr.slice(ruleStr.lastIndexOf(']') + 2).trim()}`; // console.log(ruleArr[index]);
41
+ }
56
42
 
43
+ selectorArr[index] = `${singleSelectorStr.slice(0, singleSelectorStr.lastIndexOf(']') + 1).trim()} ${selector}${singleSelectorStr.slice(singleSelectorStr.lastIndexOf(']') + 2).trim()}`;
57
44
  return;
58
45
  }
59
46
 
60
- const keyMatch = checkFilename(filename, data);
61
- ruleArr[index] = data[keyMatch] ? `${data[keyMatch].defaultSelector}${ruleStr}` : `${defaultSelector}${ruleStr}`;
47
+ selectorArr[index] = `${selector}${singleSelectorStr}`;
62
48
  });
63
- rule.selector = ruleArr.join(',\n'); // console.log(`${rule.selector} converted`);
49
+ rule.selector = selectorArr.join(',\n');
64
50
  });
65
51
  return rootOriginal;
66
52
  }
67
53
 
68
- function ignoreFile(excludeArr, filename) {
69
- let ignore = false;
70
- excludeArr.forEach(exclStr => {
71
- if (filename.includes(exclStr)) {
72
- ignore = true;
73
- }
74
- });
75
- return ignore;
76
- }
77
-
78
54
  class SelectorPlugin {
79
55
  constructor(options = {}) {
80
56
  this.optimize = options.optimize;
81
57
  this.selectorWeightConfig = options.selectorWeightConfig;
82
58
  this.exclude = options.exclude;
59
+ this.patterns = options.patterns;
60
+ this.rootDir = options.patternsRootDir;
83
61
  }
84
62
 
85
63
  apply(compiler) {
@@ -94,44 +72,54 @@ class SelectorPlugin {
94
72
  const data = JSON.parse(rawdata);
95
73
  this.exclude = (0, _windowsModification.windowsModification)(this.exclude);
96
74
  compiler.hooks.compilation.tap('selector-weight-rewrite', compilation => {
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
75
  compilation.hooks.optimizeModules.tap('selector-weight-rewrite', modules => {
120
76
  const mods = modules.filter(x => x.type.includes('css'));
121
77
  mods.forEach(module => {
122
78
  const rootOriginal = _postcss.default.parse(module.content);
123
79
 
124
80
  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(); // );
81
+ /*
82
+ input :
83
+ filename : 'D:/MyWork/..../desk_client_app/supportapp/src/components/Avatar/Avatar.module.css,
84
+
85
+ patterns.cssVariableReplacement:
86
+ // include src folder, include deskapp folder, exclude node modules
87
+ "selectorWeight": [
88
+ "src",
89
+ "deskapp",
90
+ "!node_modules"
91
+ ]
92
+ rootDir : patternsRootDir : 'supportapp'
93
+
94
+ output :
95
+ true or false
96
+ */
97
+
98
+ if (!(0, _fileHandling.isFileNameMatchingPluginPattern)({
99
+ filename,
100
+ filterArr: this.patterns.selectorWeight,
101
+ rootDir: this.rootDir
102
+ })) {
103
+ return;
134
104
  }
105
+ /*
106
+
107
+ filename : Deskapp.module.css ?
108
+ data :
109
+ {
110
+ "DeskApp.module.css": {"defaultSelector" : ".desk_app_ui "}
111
+ }
112
+ selectorWeightConfig :
113
+ defaultSelector : .zoho_desk_ui
114
+
115
+ case filename = 'DeskApp.module.css' ?
116
+ data[filename].defaultSelector = '.desk_app_ui'
117
+ case filename is different ?
118
+ defaultSelector = '.zoho_desk_ui'
119
+ */
120
+
121
+
122
+ module.content = selectorWeightPrefixAdder(rootOriginal, data[filename] ? data[filename].defaultSelector : defaultSelector, excludeStrings).toString();
135
123
  });
136
124
  });
137
125
  });
@@ -9,6 +9,8 @@ var _postcss = _interopRequireDefault(require("postcss"));
9
9
 
10
10
  var _ErrorHandler = require("../postcss-plugins/variableModificationPlugin/ErrorHandler");
11
11
 
12
+ var _fileHandling = require("./utils/fileHandling");
13
+
12
14
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
13
15
 
14
16
  // import { RawSource } from 'webpack-sources';
@@ -62,7 +64,7 @@ function extractVariableName(val) {
62
64
  return val.replace(/calc\((.+)\)/gi, '$1').replace(/var\((.+)\)/gi, '$1').replace('-1', '').replace('*', '').replace('\n', '').trim();
63
65
  }
64
66
 
65
- function rootConvertor(rootOriginal, variables, settingsObject) {
67
+ function variableConvertor(rootOriginal, variables, settingsObject) {
66
68
  rootOriginal.walkRules(rule => {
67
69
  rule.nodes.forEach((decl, index) => {
68
70
  const prevNode = rule.nodes[index - 1];
@@ -118,10 +120,12 @@ class VariableConversionCollector {
118
120
  constructor(options = {}) {
119
121
  this.optimize = options.optimize;
120
122
  this.filename = options.cssVariableReplacementConfig;
121
- this.fileHandler();
123
+ this.patterns = options.patterns;
124
+ this.rootDir = options.patternsRootDir;
125
+ this.initializeFiles();
122
126
  }
123
127
 
124
- fileHandler() {
128
+ initializeFiles() {
125
129
  createFolderIfNonExistant('./.cli/logs/');
126
130
  createFolderIfNonExistant('./.cli/config/variables/');
127
131
  createFolderIfNonExistant('./.cli/config/selectorWeight/');
@@ -131,7 +135,8 @@ class VariableConversionCollector {
131
135
 
132
136
  apply(compiler) {
133
137
  const variables = {};
134
- const unassigned = {};
138
+ const unassigned = {}; // console.log(windowsModification([this.filename])[0]);
139
+
135
140
  const rawdata = fs.readFileSync(this.filename);
136
141
  const data = JSON.parse(rawdata);
137
142
  const {
@@ -238,7 +243,7 @@ class VariableConversionCollector {
238
243
  });
239
244
  }
240
245
  });
241
- }); // -- conversion for the root using rootConvertor --
246
+ }); // -- conversion for the root using variableConvertor --
242
247
 
243
248
  /*
244
249
  input :
@@ -256,9 +261,35 @@ class VariableConversionCollector {
256
261
  compilation.hooks.optimizeModules.tap('VariableConversionCollector', modules => {
257
262
  const mods = modules.filter(x => x.type.includes('css'));
258
263
  mods.forEach(module => {
264
+ const filename = module.issuer.resource;
265
+ /*
266
+ input :
267
+ filename : 'D:/MyWork/..../desk_client_app/supportapp/src/components/Avatar/Avatar.module.css,
268
+
269
+ patterns.cssVariableReplacement:
270
+ // include src folder, include deskapp folder, exclude node modules
271
+ "cssVariableReplacement": [
272
+ "src",
273
+ "deskapp",
274
+ "!node_modules"
275
+ ]
276
+ rootDir : patternsRootDir : 'supportapp'
277
+
278
+ output :
279
+ true or false
280
+ */
281
+
282
+ if (!(0, _fileHandling.isFileNameMatchingPluginPattern)({
283
+ filename,
284
+ filterArr: this.patterns.cssVariableReplacement,
285
+ rootDir: this.rootDir
286
+ })) {
287
+ return;
288
+ }
289
+
259
290
  const rootOriginal = _postcss.default.parse(module.content);
260
291
 
261
- module.content = rootConvertor(rootOriginal, variables, settingsObject).toString();
292
+ module.content = variableConvertor(rootOriginal, variables, settingsObject).toString();
262
293
  });
263
294
  });
264
295
  });
@@ -292,29 +323,7 @@ class VariableConversionCollector {
292
323
  if (a.type < b.type) {
293
324
  return -1;
294
325
  }
295
- }); // variable constructed now to be written in a json file
296
- // const newVars = Object.keys(variables)
297
- // //Filter Object with key contanis "NAME"
298
- // .filter(key => variables[key].includes('--'))
299
- // .reduce(
300
- // (obj, key) =>
301
- // Object.assign(obj, {
302
- // [key]: variables[key]
303
- // }),
304
- // {}
305
- // );
306
- // console.log('new variables: ', newVars);
307
- // try {
308
- // fs.writeFileSync('./variableMapping.json', JSON.stringify(variables));
309
- // } catch (err) {
310
- // console.log(err);
311
- // }
312
- // fs.writeFile('./variableMapping.json', JSON.stringify(variables), err => {
313
- // if (err) {
314
- // throw err;
315
- // }
316
- // console.log('variable mapping file generated.');
317
- // });
326
+ });
318
327
 
319
328
  if (errorConsoleStatus) {
320
329
  const errorHandler = new _ErrorHandler.ErrorHandler();
@@ -15,6 +15,12 @@ Object.defineProperty(exports, "CleanUpStatsPlugin", {
15
15
  return _CleanupStatsPlugin.default;
16
16
  }
17
17
  });
18
+ Object.defineProperty(exports, "ComposeMinificationPlugin", {
19
+ enumerable: true,
20
+ get: function () {
21
+ return _ComposeMinification.default;
22
+ }
23
+ });
18
24
  Object.defineProperty(exports, "EFCPlugin", {
19
25
  enumerable: true,
20
26
  get: function () {
@@ -33,6 +39,12 @@ Object.defineProperty(exports, "ManifestPlugin", {
33
39
  return _ManifestPlugin.default;
34
40
  }
35
41
  });
42
+ Object.defineProperty(exports, "MinifyPlugin", {
43
+ enumerable: true,
44
+ get: function () {
45
+ return _MinifyPlugin.default;
46
+ }
47
+ });
36
48
  Object.defineProperty(exports, "ModuleStatsPlugin", {
37
49
  enumerable: true,
38
50
  get: function () {
@@ -99,12 +111,6 @@ Object.defineProperty(exports, "TPHashMappingPlugin", {
99
111
  return _TPHashMappingPlugin.default;
100
112
  }
101
113
  });
102
- Object.defineProperty(exports, "UglifyCSSPlugin", {
103
- enumerable: true,
104
- get: function () {
105
- return _UglifyCSSPlugin.default;
106
- }
107
- });
108
114
  Object.defineProperty(exports, "UnusedFilesFindPlugin", {
109
115
  enumerable: true,
110
116
  get: function () {
@@ -126,10 +132,12 @@ var _OptimizeJSPlugin = _interopRequireDefault(require("./OptimizeJSPlugin"));
126
132
 
127
133
  var _ResourceHintsPlugin = _interopRequireDefault(require("./ResourceHintsPlugin"));
128
134
 
129
- var _UglifyCSSPlugin = _interopRequireDefault(require("./UglifyCSSPlugin"));
135
+ var _MinifyPlugin = _interopRequireDefault(require("./MinifyPlugin"));
130
136
 
131
137
  var _ManifestPlugin = _interopRequireDefault(require("./ManifestPlugin"));
132
138
 
139
+ var _ComposeMinification = _interopRequireDefault(require("./ComposeMinification"));
140
+
133
141
  var _CleanupStatsPlugin = _interopRequireDefault(require("./CleanupStatsPlugin"));
134
142
 
135
143
  var _EFCPlugin = _interopRequireDefault(require("./EFCPlugin"));
@@ -8,7 +8,7 @@ exports.isAtRule = isAtRule;
8
8
  exports.isInsideMediaQuery = isInsideMediaQuery;
9
9
 
10
10
  function hasPrevNodeIgnore(index, prevNode, ignoreComment) {
11
- return index !== 0 && prevNode.type && prevNode.type === 'comment' && prevNode.text.toLowerCase() === ignoreComment;
11
+ return index !== 0 && prevNode && prevNode.type && prevNode.type === 'comment' && prevNode.text.toLowerCase() === ignoreComment;
12
12
  }
13
13
 
14
14
  function isAtRule(rule) {
@@ -16,13 +16,5 @@ function isAtRule(rule) {
16
16
  }
17
17
 
18
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;
19
+ return isAtRule(rule) && rule.parent && rule.parent.name === 'media' ? true : false;
28
20
  }
@@ -3,120 +3,90 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- exports.filterFile = filterFile;
7
- exports.ignoreFile = ignoreFile;
6
+ exports.isFileNameMatchingPattern = isFileNameMatchingPattern;
7
+ exports.isFileNameMatchingPluginPattern = isFileNameMatchingPluginPattern;
8
8
 
9
9
  var _windowsModification = require("../../loaderUtils/windowsModification");
10
10
 
11
- var _checkPattern = require("./checkPattern");
11
+ var _ignore = _interopRequireDefault(require("ignore"));
12
12
 
13
- const ignore = require('ignore');
13
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
14
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
- }
15
+ let aliasNames = {
16
+ valueReplacer: 'postcss-value-replacer',
17
+ selectorReplace: 'postcss-selector-replace-new',
18
+ hasRTL: 'postcss-rtl',
19
+ combinerMediaQuery: 'postcss-combine-media-query',
20
+ hoverActive: 'postcss-mobile-hover',
21
+ cssVariableReplacement: 'postcss-variable-report',
22
+ composeMinification: 'postcss-compose-plugin'
23
+ };
24
+ /*
25
+
26
+ unique scenario
27
+
28
+ */
29
+ // export function filterFileCssUniqueness(filename, filterObj) {
30
+ // let rootDir = 'supportapp';
31
+ // let include = false;
32
+ // const regex = `^(.+?)${rootDir}?\\\\`;
33
+ // const newFilename = windowsModificationFile(filename).replace(
34
+ // new RegExp(regex, 'gi'),
35
+ // ''
36
+ // );
37
+ // Object.keys(filterObj).forEach(key => {
38
+ // const ig = ignore().add(filterObj[key]);
39
+ // if (ig.ignores(newFilename)) {
40
+ // include = true;
41
+ // }
42
+ // });
43
+ // return include;
44
+ // }
33
45
 
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
46
+ function isFileNameMatchingPattern({
47
+ filename,
48
+ filterObject,
49
+ plugins,
50
+ rootDir
51
+ }) {
52
+ const finalPlugins = []; // console.log(rootDir);
48
53
 
49
- };
50
- const finalPlugins = [];
54
+ const regex = `^(.+?)${rootDir}?\\\\`;
55
+ const newFilename = (0, _windowsModification.windowsModificationFile)(filename).replace(new RegExp(regex, 'gi'), '');
51
56
  Object.keys(filterObject).forEach(key => {
52
- // console.log(key, filterObject[key], aliasNames);
53
- // console.log(key);
54
57
  plugins.forEach(x => {
55
- let include = false;
56
-
58
+ // console.log(key, x.postcssPlugin);
57
59
  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]);
60
+ const ig = (0, _ignore.default)().add(filterObject[key]);
89
61
 
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
- // }
62
+ if (ig.ignores(newFilename)) {
63
+ // console.log(newFilename);
64
+ finalPlugins.push(x);
65
+ }
108
66
  }
109
67
  });
110
- }); // if (include) {
111
- // console.log('before: ', plugins);
112
- // console.log('after: ');
113
- // console.log(finalPlugins);
114
- // }
115
- // console.log(filename);
68
+ }); // console.log(filename);
116
69
  // console.log(finalPlugins);
117
- // console.log(
118
- // '-------------------------------------------------------------------------------------------------'
119
- // );
70
+ // console.log('----------------------------------------------------------------------')
120
71
 
121
72
  return finalPlugins; // console.log(filename, filterObject);
73
+ }
74
+
75
+ function isFileNameMatchingPluginPattern({
76
+ filename,
77
+ filterArr,
78
+ rootDir
79
+ }) {
80
+ let include = true; // console.log(rootDir);
81
+
82
+ const regex = `^(.+?)${rootDir}?\\\\`; // console.log(plugin);
83
+
84
+ const newFilename = (0, _windowsModification.windowsModificationFile)(filename).replace(new RegExp(regex, 'gi'), '');
85
+ const ig = (0, _ignore.default)().add(filterArr);
86
+
87
+ if (!ig.ignores(newFilename)) {
88
+ include = false;
89
+ }
90
+
91
+ return include;
122
92
  }
@@ -0,0 +1,30 @@
1
+ "use strict";
2
+
3
+ const ignore = require('ignore');
4
+
5
+ const ignoreArr1 = ['src', '!src\\components', 'src\\Accessibility'];
6
+ const ignoreArr2 = ['src\\', '!node_modules\\'];
7
+ const ignoreArr3 = ['*'];
8
+
9
+ const {
10
+ windowsModificationFile
11
+ } = require('../../../../lib/loaderUtils/windowsModification');
12
+
13
+ const files = ['D:\\MyWork\\React Build\\desk_client_app\\jsapps\\supportapp\\src\\components\\Accessibility\\Accessibility.module.css', 'D:\\MyWork\\React Build\\desk_client_app\\jsapps\\supportapp\\src\\components\\Avatar\\Avatar.module.css', 'D:/MyWork/React Build/desk_client_app/jsapps/supportapp/src/components/Accessibility/Accessibility.module.css', 'D:/MyWork/React Build/desk_client_app/jsapps/supportapp/src/components/Accessibility/AccessibilityNavigation.module.css', 'desk_client_app\\jsapps\\supportapp\\src\\components\\Test.module.css', 'desk_client_app\\jsapps\\supportapp\\src\\components\\Accessibility\\Accessibility.module.css', 'desk_client_app/jsapps/supportapp/src/components/Accessibility/Accessibility.module.css', 'src\\components\\Accessibility\\Accessibility.module.css', 'src/components/Accessibility/Accessibility.module.css', 'Accessibility.module.css', ''];
14
+ const ignore1 = ignore().add(ignoreArr1);
15
+ const ignore2 = ignore().add(ignoreArr2);
16
+ const ignore3 = ignore().add(ignoreArr3);
17
+ files.forEach(file => {
18
+ // console.log(file);
19
+ const rootDir = 'supportapp';
20
+ const regex = `^(.+?)${rootDir}?\\\\`;
21
+ const newFilename = windowsModificationFile(file).replace(new RegExp(regex, 'gi'), '');
22
+ console.log(newFilename);
23
+
24
+ if (newFilename.trim() !== '') {
25
+ console.log(ignore1.ignores(newFilename));
26
+ console.log(ignore2.ignores(newFilename));
27
+ console.log(ignore3.ignores(newFilename));
28
+ console.log('--------------------------------------------------------------------');
29
+ }
30
+ });
@@ -0,0 +1,8 @@
1
+ "use strict";
2
+
3
+ var _postcss = _interopRequireDefault(require("postcss"));
4
+
5
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
6
+
7
+ module.exports = _postcss.default.plugin('postcss-empty', () => (root, result) => {// console.log(root.source.input.from, result);
8
+ });
@@ -10,7 +10,7 @@ module.exports = _postcss.default.plugin('postcss-exclude-files', opts => {
10
10
  } = opts;
11
11
  return (root, result) => {
12
12
  const inputFile = root.source.input.file;
13
- let isIgnoredFile = opts.ignore.some(file => inputFile.indexOf(file) !== -1);
13
+ const isIgnoredFile = opts.ignore.some(file => inputFile.indexOf(file) !== -1);
14
14
 
15
15
  if (!isIgnoredFile) {
16
16
  const handler = response => response.messages.forEach(msg => result.messages.push(msg));