@zohodesk/react-cli 1.0.1 → 1.0.2-exp.1
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 +1165 -1160
- package/bin/cli.js +483 -483
- 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/warnings_while_install.txt +35 -35
- package/files/eslintrc.js +62 -62
- package/files/prettierrc.js +3 -3
- 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 +79 -50
- package/lib/loaderUtils/tests/windowsModification.test.js +10 -0
- package/lib/loaderUtils/windowsModification.js +6 -1
- package/lib/loaders/composeLoader.js +175 -0
- package/lib/loaders/workerLoader.js +9 -9
- package/lib/pluginUtils/getDevPlugins.js +18 -7
- package/lib/pluginUtils/getProdPlugins.js +6 -6
- package/lib/pluginUtils/getUMDCSSPlugins.js +1 -1
- package/lib/pluginUtils/getUMDComponentPlugins.js +1 -1
- 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 +56 -45
- package/lib/plugins/ServiceWorkerPlugin.js +9 -9
- package/lib/plugins/TPHashMappingPlugin.js +4 -4
- package/lib/plugins/VariableConversionCollector.js +93 -84
- package/lib/plugins/index.js +15 -7
- package/lib/plugins/utils/classHandling.js +20 -0
- package/lib/plugins/utils/fileHandling.js +92 -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/SelectorReplace.js +80 -0
- package/lib/postcss-plugins/ValueReplacer.js +2 -13
- package/lib/postcss-plugins/__test__/selectorReplace.test.js +28 -0
- 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/postcss-plugins/variableModifier.js +1 -1
- package/lib/schemas/index.js +34 -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 +35 -7
- package/lib/utils/resultSchema.json +73 -73
- 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/.vscode/settings.json +0 -11
- package/lib/plugins/composeCommonPlugin.js +0 -30
- package/result.json +0 -1
- package/unittest/index.html +0 -37
@@ -9,32 +9,24 @@ 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
22
|
const prevNode = 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
|
-
return;
|
37
|
-
}
|
28
|
+
if (!(0, _classHandling.isInsideMediaQuery)(rule)) {
|
29
|
+
return;
|
38
30
|
}
|
39
31
|
|
40
32
|
const selectorArr = rule.selector.split(',');
|
@@ -46,40 +38,26 @@ function rootConvertor(rootOriginal, defaultSelector, data, filename, excludeStr
|
|
46
38
|
if (singleSelectorStr.includes(']')) {
|
47
39
|
if (singleSelectorStr.slice(singleSelectorStr.lastIndexOf(']') + 2).trim() === '') {
|
48
40
|
return;
|
49
|
-
}
|
50
|
-
// rule.slice(rule.lastIndexOf(']') + 2).trim(),
|
51
|
-
// rule.slice(rule.lastIndexOf(']') + 2).trim() !== ''
|
52
|
-
// );
|
53
|
-
|
54
|
-
|
55
|
-
selectorArr[index] = `${singleSelectorStr.slice(0, singleSelectorStr.lastIndexOf(']') + 1).trim()} ${defaultSelector}${singleSelectorStr.slice(singleSelectorStr.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
|
-
|
61
|
-
selectorArr[index] = data[keyMatch] ? `${data[keyMatch].defaultSelector}${singleSelectorStr}` : `${defaultSelector}${singleSelectorStr}`;
|
47
|
+
selectorArr[index] = `${selector}${singleSelectorStr}`;
|
62
48
|
});
|
63
|
-
rule.selector = selectorArr.join(',\n');
|
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) {
|
@@ -99,16 +77,49 @@ class SelectorPlugin {
|
|
99
77
|
mods.forEach(module => {
|
100
78
|
const rootOriginal = _postcss.default.parse(module.content);
|
101
79
|
|
102
|
-
const filename = module.issuer.resource;
|
103
|
-
|
104
|
-
|
80
|
+
const filename = module.issuer.resource;
|
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
|
+
})) {
|
105
103
|
return;
|
106
|
-
}
|
107
|
-
|
108
|
-
|
109
|
-
module.
|
110
|
-
|
111
|
-
|
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();
|
112
123
|
});
|
113
124
|
});
|
114
125
|
});
|
@@ -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,12 @@ 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;
|
125
|
+
this.initializeFiles();
|
122
126
|
}
|
123
127
|
|
124
|
-
|
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 {
|
@@ -154,13 +159,13 @@ class VariableConversionCollector {
|
|
154
159
|
}
|
155
160
|
};
|
156
161
|
}
|
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
|
162
|
+
/*
|
163
|
+
purpose of tap : to create a variable object such as:
|
164
|
+
{
|
165
|
+
--zdt_uploadlist_default_width : width,
|
166
|
+
--zdt_uploadlist_default_height : height,
|
167
|
+
}
|
168
|
+
which will help in the conversion further
|
164
169
|
*/
|
165
170
|
|
166
171
|
|
@@ -216,19 +221,19 @@ class VariableConversionCollector {
|
|
216
221
|
});
|
217
222
|
});
|
218
223
|
});
|
219
|
-
/*
|
220
|
-
current value example:
|
221
|
-
{
|
222
|
-
--zdt_uploadlist_default_width : --zd_upload_width,
|
223
|
-
--zd_upload_width : width
|
224
|
-
}
|
225
|
-
expected value :
|
226
|
-
{
|
227
|
-
--zdt_uploadlist_default_width : width,
|
228
|
-
--zd_upload_width : width
|
229
|
-
}
|
230
|
-
|
231
|
-
conversion is done in the while loop below
|
224
|
+
/*
|
225
|
+
current value example:
|
226
|
+
{
|
227
|
+
--zdt_uploadlist_default_width : --zd_upload_width,
|
228
|
+
--zd_upload_width : width
|
229
|
+
}
|
230
|
+
expected value :
|
231
|
+
{
|
232
|
+
--zdt_uploadlist_default_width : width,
|
233
|
+
--zd_upload_width : width
|
234
|
+
}
|
235
|
+
|
236
|
+
conversion is done in the while loop below
|
232
237
|
*/
|
233
238
|
|
234
239
|
Object.keys(variables).forEach(key => {
|
@@ -238,36 +243,62 @@ class VariableConversionCollector {
|
|
238
243
|
});
|
239
244
|
}
|
240
245
|
});
|
241
|
-
}); // -- conversion for the root using
|
242
|
-
|
243
|
-
/*
|
244
|
-
input :
|
245
|
-
.a{
|
246
|
-
padding : 20px
|
247
|
-
}
|
248
|
-
output :
|
249
|
-
// on settingObject file :
|
250
|
-
{ padding : { replacements : { px : 'zd_size$$' }}}
|
251
|
-
.a{
|
252
|
-
padding : zd_size20;
|
253
|
-
}
|
246
|
+
}); // -- conversion for the root using variableConvertor --
|
247
|
+
|
248
|
+
/*
|
249
|
+
input :
|
250
|
+
.a{
|
251
|
+
padding : 20px
|
252
|
+
}
|
253
|
+
output :
|
254
|
+
// on settingObject file :
|
255
|
+
{ padding : { replacements : { px : 'zd_size$$' }}}
|
256
|
+
.a{
|
257
|
+
padding : zd_size20;
|
258
|
+
}
|
254
259
|
*/
|
255
260
|
|
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 =
|
292
|
+
module.content = variableConvertor(rootOriginal, variables, settingsObject).toString();
|
262
293
|
});
|
263
294
|
});
|
264
295
|
});
|
265
|
-
/*
|
266
|
-
purpose of tap : to display the errors encountered so far
|
267
|
-
input :
|
268
|
-
all css files
|
269
|
-
output :
|
270
|
-
all errors that are present in the errTable arr
|
296
|
+
/*
|
297
|
+
purpose of tap : to display the errors encountered so far
|
298
|
+
input :
|
299
|
+
all css files
|
300
|
+
output :
|
301
|
+
all errors that are present in the errTable arr
|
271
302
|
*/
|
272
303
|
|
273
304
|
compiler.hooks.afterEmit.tap('error-display', () => {
|
@@ -292,29 +323,7 @@ class VariableConversionCollector {
|
|
292
323
|
if (a.type < b.type) {
|
293
324
|
return -1;
|
294
325
|
}
|
295
|
-
});
|
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();
|
package/lib/plugins/index.js
CHANGED
@@ -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
|
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"));
|
@@ -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,92 @@
|
|
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
|
+
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
|
+
// }
|
45
|
+
|
46
|
+
function isFileNameMatchingPattern({
|
47
|
+
filename,
|
48
|
+
filterObject,
|
49
|
+
plugins,
|
50
|
+
rootDir
|
51
|
+
}) {
|
52
|
+
const finalPlugins = []; // console.log(rootDir);
|
53
|
+
|
54
|
+
const regex = `^(.+?)${rootDir}?\\\\`;
|
55
|
+
const newFilename = (0, _windowsModification.windowsModificationFile)(filename).replace(new RegExp(regex, 'gi'), '');
|
56
|
+
Object.keys(filterObject).forEach(key => {
|
57
|
+
plugins.forEach(x => {
|
58
|
+
// console.log(key, x.postcssPlugin);
|
59
|
+
if (aliasNames[key] === x.postcssPlugin) {
|
60
|
+
const ig = (0, _ignore.default)().add(filterObject[key]);
|
61
|
+
|
62
|
+
if (ig.ignores(newFilename)) {
|
63
|
+
// console.log(newFilename);
|
64
|
+
finalPlugins.push(x);
|
65
|
+
}
|
66
|
+
}
|
67
|
+
});
|
68
|
+
}); // console.log(filename);
|
69
|
+
// console.log(finalPlugins);
|
70
|
+
// console.log('----------------------------------------------------------------------')
|
71
|
+
|
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;
|
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
|
-
|
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));
|