@zohodesk/react-cli 1.0.2 → 1.0.3-exp.2
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.
- package/.eslintignore +7 -7
- package/.eslintrc.js +180 -180
- package/.prettierrc +6 -6
- package/Changelog.md +1019 -1019
- package/README.md +1209 -1165
- package/bin/cli.js +489 -483
- package/docs/ComposeMinification.md +14 -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/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/common/testPattern.js +0 -2
- package/lib/common/valueReplacer.js +1 -3
- package/lib/configs/resolvers.js +14 -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 +78 -49
- 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/selectorMappingLoader.js +9 -9
- package/lib/loaders/workerLoader.js +9 -9
- package/lib/logger.js +20 -0
- package/lib/pluginUtils/getDevPlugins.js +23 -8
- package/lib/pluginUtils/getProdPlugins.js +20 -8
- package/lib/pluginUtils/getUMDCSSPlugins.js +1 -1
- package/lib/pluginUtils/getUMDComponentPlugins.js +1 -1
- package/lib/plugins/CustomAttributePlugin.js +82 -0
- package/lib/plugins/CustomAttributePlugin.md +35 -0
- package/lib/plugins/EFCPlugin.js +9 -9
- package/lib/plugins/EFCPlugin.md +6 -6
- package/lib/plugins/EFCTemplatePlugin.js +10 -12
- package/lib/plugins/I18NInjectIntoIndexPlugin.js +12 -13
- package/lib/plugins/I18nSplitPlugin/I18nDebugPlugin.js +2 -3
- package/lib/plugins/I18nSplitPlugin/I18nDownlodLogic.js +38 -38
- package/lib/plugins/I18nSplitPlugin/I18nFilesEmitter.js +30 -30
- package/lib/plugins/I18nSplitPlugin/I18nKeysIdentifer.js +10 -15
- 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/I18nSplitPlugin/utils/propertiesUtils.js +8 -8
- 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 +66 -48
- package/lib/plugins/ServiceWorkerPlugin.js +9 -9
- package/lib/plugins/TPHashMappingPlugin.js +4 -4
- package/lib/plugins/VariableConversionCollector.js +94 -88
- 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/IncludePlugin.js +0 -1
- package/lib/postcss-plugins/RTLSplitPlugin.js +14 -20
- package/lib/postcss-plugins/ValueReplacer.js +2 -13
- 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 -9
- package/lib/postcss-plugins/variableModificationPlugin/index.js +2 -21
- package/lib/schemas/index.js +39 -4
- package/lib/servers/devBuild.js +13 -11
- package/lib/servers/httpsOptions.js +12 -13
- package/lib/servers/nowatchserver.js +5 -3
- package/lib/servers/requireLocalOrGlobal.js +61 -0
- package/lib/servers/server.js +3 -5
- 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 +38 -12
- package/lib/utils/getOptions.js +9 -0
- package/lib/utils/resultSchema.json +73 -73
- package/lib/utils/variableConvertor.js +159 -0
- package/npm8.md +9 -9
- package/package-lock.json +14412 -0
- package/package.json +121 -120
- 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 -244
- package/result.json +0 -1
- package/unittest/index.html +0 -37
|
@@ -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
|
|
|
@@ -190,9 +196,6 @@ class VariableConversionCollector {
|
|
|
190
196
|
variables[extractedValue] = decl.prop;
|
|
191
197
|
} else {
|
|
192
198
|
if (new RegExp(supportedProps.join('|'), 'gi').test(decl.prop)) {
|
|
193
|
-
// console.log(
|
|
194
|
-
// `${extractedValue} : ${variables[extractedValue]} already exists please check!`
|
|
195
|
-
// );
|
|
196
199
|
if (errorsAllowed.MULTIPLE_OCCURANCES) {
|
|
197
200
|
const errObj = {
|
|
198
201
|
decl,
|
|
@@ -206,7 +209,6 @@ class VariableConversionCollector {
|
|
|
206
209
|
}
|
|
207
210
|
}
|
|
208
211
|
} else {
|
|
209
|
-
// console.log(decl.prop);
|
|
210
212
|
if (/^--/gi.test(decl.prop) && val.trim() !== '' && !variables[decl.prop]) {
|
|
211
213
|
if (!Object.keys(variablesRead.ignore).includes(decl.prop)) {
|
|
212
214
|
unassigned[decl.prop] = variables[decl.prop];
|
|
@@ -216,19 +218,19 @@ class VariableConversionCollector {
|
|
|
216
218
|
});
|
|
217
219
|
});
|
|
218
220
|
});
|
|
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
|
|
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
|
|
232
234
|
*/
|
|
233
235
|
|
|
234
236
|
Object.keys(variables).forEach(key => {
|
|
@@ -238,36 +240,62 @@ class VariableConversionCollector {
|
|
|
238
240
|
});
|
|
239
241
|
}
|
|
240
242
|
});
|
|
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
|
-
}
|
|
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
|
+
}
|
|
254
256
|
*/
|
|
255
257
|
|
|
256
258
|
compilation.hooks.optimizeModules.tap('VariableConversionCollector', modules => {
|
|
257
259
|
const mods = modules.filter(x => x.type.includes('css'));
|
|
258
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
|
+
|
|
259
287
|
const rootOriginal = _postcss.default.parse(module.content);
|
|
260
288
|
|
|
261
|
-
module.content =
|
|
289
|
+
module.content = variableConvertor(rootOriginal, variables, settingsObject).toString();
|
|
262
290
|
});
|
|
263
291
|
});
|
|
264
292
|
});
|
|
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
|
|
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
|
|
271
299
|
*/
|
|
272
300
|
|
|
273
301
|
compiler.hooks.afterEmit.tap('error-display', () => {
|
|
@@ -292,29 +320,7 @@ class VariableConversionCollector {
|
|
|
292
320
|
if (a.type < b.type) {
|
|
293
321
|
return -1;
|
|
294
322
|
}
|
|
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
|
-
// });
|
|
323
|
+
});
|
|
318
324
|
|
|
319
325
|
if (errorConsoleStatus) {
|
|
320
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));
|
|
@@ -13,7 +13,6 @@ module.exports = _postcss.default.plugin('postcss-include-files', opts => {
|
|
|
13
13
|
const includeFile = opts.include.some(file => inputFile.indexOf(file) !== -1);
|
|
14
14
|
|
|
15
15
|
if (includeFile) {
|
|
16
|
-
// console.log(inputFile);
|
|
17
16
|
const handler = response => response.messages.forEach(msg => result.messages.push(msg));
|
|
18
17
|
|
|
19
18
|
return (0, _postcss.default)(plugins).process(root, {
|
|
@@ -18,7 +18,6 @@ const oppositeDir = {
|
|
|
18
18
|
};
|
|
19
19
|
|
|
20
20
|
function compareSelector(selector1, selector2) {
|
|
21
|
-
// console.log({ selector1, selector2 }, selector1 === selector2);
|
|
22
21
|
return selector1 === selector2;
|
|
23
22
|
}
|
|
24
23
|
|
|
@@ -38,11 +37,11 @@ function selectorMinifySameDir(selector, direction) {
|
|
|
38
37
|
const regex = getRegex(direction);
|
|
39
38
|
return selector.replace(regex, '').trim();
|
|
40
39
|
}
|
|
41
|
-
/**
|
|
42
|
-
* this funtion will remove given rule,
|
|
43
|
-
* if given selector and it's previous sibiling rule selector are same
|
|
44
|
-
* current rule properties will move to previous sibiling rule.
|
|
45
|
-
* @param {Rule} rule current rule
|
|
40
|
+
/**
|
|
41
|
+
* this funtion will remove given rule,
|
|
42
|
+
* if given selector and it's previous sibiling rule selector are same
|
|
43
|
+
* current rule properties will move to previous sibiling rule.
|
|
44
|
+
* @param {Rule} rule current rule
|
|
46
45
|
*/
|
|
47
46
|
|
|
48
47
|
|
|
@@ -57,16 +56,15 @@ function mergeIfSameSelector(rule) {
|
|
|
57
56
|
rule.remove();
|
|
58
57
|
}
|
|
59
58
|
}
|
|
60
|
-
/**
|
|
61
|
-
* this funtion will remove given rule,
|
|
62
|
-
* if given selector and it's previous sibiling rule selector are same
|
|
63
|
-
* current rule properties will move to previous sibiling rule.
|
|
64
|
-
* @param {Rule} rule current rule
|
|
59
|
+
/**
|
|
60
|
+
* this funtion will remove given rule,
|
|
61
|
+
* if given selector and it's previous sibiling rule selector are same
|
|
62
|
+
* current rule properties will move to previous sibiling rule.
|
|
63
|
+
* @param {Rule} rule current rule
|
|
65
64
|
*/
|
|
66
65
|
|
|
67
66
|
|
|
68
67
|
function removeIfOppsiteDirRule(rule, direction, rootOptions) {
|
|
69
|
-
// console.log({ rule, type: rule.type });
|
|
70
68
|
const selectors = rule.selector.split(/\s*,\s*/); // NOTE: if we use opposite dir selector as custom override reason,
|
|
71
69
|
// and compain normal selector with it, In this case
|
|
72
70
|
// we just a have to remove that selector only not full rule
|
|
@@ -87,11 +85,10 @@ function removeIfOppsiteDirRule(rule, direction, rootOptions) {
|
|
|
87
85
|
}
|
|
88
86
|
|
|
89
87
|
function removeIfOppsiteDirKeyframe(rule, direction) {
|
|
90
|
-
|
|
91
|
-
|
|
88
|
+
const name = rule.params;
|
|
89
|
+
const keyFrameDirName = name.slice(name.lastIndexOf('-') + 1);
|
|
92
90
|
|
|
93
91
|
if (keyFrameDirName === oppositeDir[direction]) {
|
|
94
|
-
// console.log({ m: 'removed', keyFrameName: rule.params });
|
|
95
92
|
rule.remove();
|
|
96
93
|
}
|
|
97
94
|
}
|
|
@@ -109,12 +106,10 @@ function separateSingleDir(root, direction, rootOptions) {
|
|
|
109
106
|
|
|
110
107
|
function separateRtlAndLtr(css, rootOptions) {
|
|
111
108
|
// let processor = postcss([]).process(css);
|
|
112
|
-
|
|
113
|
-
// console.log(processor, root);
|
|
109
|
+
const root = postcss.parse(css); // let { root } = processor;
|
|
114
110
|
// NOTE: I did first rtl then ltr , Because for ltr I use original root ref
|
|
115
111
|
|
|
116
|
-
const rtlRoot = separateSingleDir(root.clone(), 'rtl', rootOptions);
|
|
117
|
-
|
|
112
|
+
const rtlRoot = separateSingleDir(root.clone(), 'rtl', rootOptions);
|
|
118
113
|
const ltrRoot = separateSingleDir(root, 'ltr', rootOptions);
|
|
119
114
|
return {
|
|
120
115
|
ltrRoot,
|
|
@@ -132,7 +127,6 @@ function separateRtlAndLtr(css, rootOptions) {
|
|
|
132
127
|
// // root.append(postcss.comment({ text: 'comment' }));
|
|
133
128
|
// root.append(postcss.comment({ text: 'this is spliting part ' }));
|
|
134
129
|
// root.append(rtlRoot);
|
|
135
|
-
// //console.log({root, roots:root+""}, root+"")
|
|
136
130
|
// // Transform CSS AST here
|
|
137
131
|
// }
|
|
138
132
|
// );
|
|
@@ -18,7 +18,7 @@ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { de
|
|
|
18
18
|
// }
|
|
19
19
|
// };
|
|
20
20
|
// });
|
|
21
|
-
// export default
|
|
21
|
+
// export default
|
|
22
22
|
module.exports = _postcss.default.plugin('postcss-value-replacer', (valueReplacer = {}) => // Work with options here
|
|
23
23
|
root => {
|
|
24
24
|
root.walkDecls(decl => {
|
|
@@ -31,16 +31,5 @@ root => {
|
|
|
31
31
|
}
|
|
32
32
|
}); //console.log({root, roots:root+""}, root+"")
|
|
33
33
|
// Transform CSS AST here
|
|
34
|
-
});
|
|
35
|
-
// valueReplacer.forEach(obj => {
|
|
36
|
-
// if (
|
|
37
|
-
// obj.props.indexOf(decl.prop) !== -1 &&
|
|
38
|
-
// obj.values[decl.value] !== undefined
|
|
39
|
-
// ) {
|
|
40
|
-
// decl.value = obj.values[decl.value];
|
|
41
|
-
// }
|
|
42
|
-
// });
|
|
43
|
-
// //console.log({root, roots:root+""}, root+"")
|
|
44
|
-
// // Transform CSS AST here
|
|
45
|
-
// });
|
|
34
|
+
});
|
|
46
35
|
});
|