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