@zohodesk/react-cli 1.1.14-kubernetes → 1.1.15
Sign up to get free protection for your applications and to get access to all the features.
- package/.vscode/settings.json +25 -0
- package/README.md +294 -16
- package/bin/cli.js +30 -55
- package/docs/ComposeMinification.md +13 -0
- package/docs/CustomChunks.md +12 -9
- package/docs/MarkdownParser.md +18 -0
- package/docs/ReactLive.md +14 -0
- package/docs/SelectorWeight.md +3 -0
- package/docs/ValueReplacer.md +27 -0
- package/docs/VariableConversion.md +6 -1
- package/docs/patternFiltering.md +57 -0
- package/lib/common/buildEs.js +12 -0
- package/lib/common/runPreProcess.js +71 -0
- package/lib/common/splitChunks.js +65 -45
- package/lib/common/testPattern.js +9 -11
- package/lib/common/valueReplacer.js +1 -3
- package/lib/configs/resolvers.js +16 -5
- package/lib/configs/webpack.css.umd.config.js +3 -2
- package/lib/configs/webpack.dev.config.js +15 -5
- package/lib/configs/webpack.docs.config.js +17 -5
- package/lib/configs/webpack.impact.config.js +11 -4
- package/lib/configs/webpack.prod.config.js +15 -5
- package/lib/constants.js +3 -3
- package/lib/deprecationLogger.js +40 -0
- package/lib/loaderUtils/getCSSLoaders.js +98 -49
- package/lib/loaderUtils/tests/windowsModification.test.js +10 -0
- package/lib/loaderUtils/windowsModification.js +6 -1
- package/lib/loaders/__test__/markdownLoader.spec.js +145 -0
- package/lib/loaders/composeLoader.js +298 -0
- package/lib/loaders/docsLoader.js +18 -7
- package/lib/loaders/markdownLoader.js +71 -0
- package/lib/loaders/reactLiveConvertor.js +105 -0
- package/lib/loaders/selectorMappingLoader.js +9 -9
- package/lib/logger.js +27 -0
- package/lib/pluginUtils/getDevPlugins.js +25 -6
- package/lib/pluginUtils/getProdPlugins.js +32 -5
- 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/EFCTemplatePlugin.js +10 -12
- package/lib/plugins/EfcResourceCleanupPlugin.js +43 -0
- package/lib/plugins/I18NInjectIntoIndexPlugin.js +8 -9
- package/lib/plugins/I18nSplitPlugin/I18nDebugPlugin.js +2 -3
- package/lib/plugins/I18nSplitPlugin/I18nKeysIdentifer.js +2 -7
- package/lib/plugins/I18nSplitPlugin/index.js +1 -1
- package/lib/plugins/I18nSplitPlugin/utils/propertiesUtils.js +8 -8
- package/lib/plugins/{UglifyCSSPlugin.js → MinifyPlugin.js} +3 -3
- package/lib/plugins/ReportGeneratePlugin.js +8 -6
- package/lib/plugins/ResourceHintsPlugin.js +13 -3
- package/lib/plugins/SelectorPlugin.js +77 -37
- package/lib/plugins/StatsPlugin.js +82 -0
- package/lib/plugins/UnusedFilesFindPlugin.js +7 -5
- package/lib/plugins/VariableConversionCollector.js +40 -101
- package/lib/plugins/index.js +7 -7
- package/lib/plugins/utils/classHandling.js +35 -0
- package/lib/plugins/utils/fileHandling.js +92 -0
- package/lib/plugins/utils/tests/fileHandling.test.js +30 -0
- package/lib/plugins/variableConvertorUtils.js +133 -0
- package/lib/postcss-plugins/EmptyPlugin.js +8 -0
- package/lib/postcss-plugins/ExcludePlugin.js +1 -1
- package/lib/postcss-plugins/IncludePlugin.js +23 -0
- package/lib/postcss-plugins/RTLSplitPlugin.js +4 -10
- package/lib/postcss-plugins/SelectorReplace.js +80 -0
- package/lib/postcss-plugins/ValueReplacer.js +8 -29
- package/lib/postcss-plugins/__test__/selectorReplace.test.js +28 -0
- package/lib/postcss-plugins/__test__/valueReplacer.spec.js +43 -0
- package/lib/postcss-plugins/hoverActivePlugin.js +0 -6
- package/lib/postcss-plugins/variableModificationPlugin/ErrorHandler.js +0 -1
- package/lib/postcss-plugins/variableModificationPlugin/index.js +94 -38
- package/lib/schemas/index.js +95 -18
- package/lib/servers/devBuild.js +13 -11
- package/lib/servers/getCliPath.js +3 -5
- package/lib/servers/httpsOptions.js +12 -13
- package/lib/servers/nowatchserver.js +62 -55
- package/lib/servers/requireLocalOrGlobal.js +61 -0
- package/lib/servers/server.js +53 -52
- package/lib/utils/cssClassNameGenerate.js +70 -13
- package/lib/utils/deprecationSupport.js +134 -0
- package/lib/utils/getOptions.js +35 -28
- package/lib/utils/getServerURL.js +1 -9
- package/lib/utils/index.js +14 -12
- package/lib/utils/initPreCommitHook.js +5 -5
- package/lib/utils/log.js +11 -0
- package/lib/utils/object-manipulation.js +88 -0
- package/lib/utils/pullOrigin.js +3 -3
- package/lib/utils/reinstallDependencies.js +3 -3
- package/lib/utils/selectorReplacer.js +47 -0
- package/lib/utils/switchBranch.js +4 -2
- package/lib/utils/variableConverter.js +104 -0
- package/npm-shrinkwrap.json +33485 -0
- package/package.json +5 -3
- package/templates/docs/all.html +1 -0
- package/templates/docs/component.html +1 -0
- package/templates/docs/components.html +1 -0
- package/templates/docs/css/markdown.css +202 -0
- package/templates/docs/css/style.css +136 -169
- package/templates/docs/index.html +796 -632
- package/lib/plugins/composeCommonPlugin.js +0 -30
- package/lib/postcss-plugins/variableModifier.js +0 -244
@@ -29,10 +29,16 @@ var _SelectorPlugin = _interopRequireDefault(require("../plugins/SelectorPlugin"
|
|
29
29
|
|
30
30
|
var _plugins = require("../plugins");
|
31
31
|
|
32
|
+
var _CustomAttributePlugin = require("../plugins/CustomAttributePlugin");
|
33
|
+
|
32
34
|
var _RtlCssPlugin = require("../plugins/RtlSplitPlugin/RtlCssPlugin");
|
33
35
|
|
34
36
|
var _configHtmlWebpackPlugins = require("./configHtmlWebpackPlugins");
|
35
37
|
|
38
|
+
var _StatsPlugin = _interopRequireDefault(require("../plugins/StatsPlugin"));
|
39
|
+
|
40
|
+
var _EfcResourceCleanupPlugin = _interopRequireDefault(require("../plugins/EfcResourceCleanupPlugin"));
|
41
|
+
|
36
42
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
37
43
|
|
38
44
|
// eslint-disable-next-line no-unused-vars
|
@@ -45,12 +51,14 @@ const getProdPlugins = (options, publicPath = '') => {
|
|
45
51
|
bundleAnalyze,
|
46
52
|
optimize,
|
47
53
|
publicPaths,
|
54
|
+
patterns,
|
48
55
|
hasEFC: prevOptionForEnableEFC,
|
49
56
|
enableSMapHook,
|
50
57
|
tpFolder,
|
51
58
|
folder,
|
52
59
|
outputFolder,
|
53
60
|
context,
|
61
|
+
exclude,
|
54
62
|
enableSMap,
|
55
63
|
server: {
|
56
64
|
mode
|
@@ -63,6 +71,7 @@ const getProdPlugins = (options, publicPath = '') => {
|
|
63
71
|
resourceHints,
|
64
72
|
serviceWorker,
|
65
73
|
htmlTemplate,
|
74
|
+
customAttributes,
|
66
75
|
tpHashMapping,
|
67
76
|
cdnMapping,
|
68
77
|
crossorigin
|
@@ -83,6 +92,12 @@ const getProdPlugins = (options, publicPath = '') => {
|
|
83
92
|
templateFilePath,
|
84
93
|
localeAttr: efcLocaleAttr
|
85
94
|
} = options.efc;
|
95
|
+
const {
|
96
|
+
enable: enableStats,
|
97
|
+
options: statsOptions,
|
98
|
+
excludeKeys: statsOutputExcludeKeys,
|
99
|
+
fileName: statsFileName
|
100
|
+
} = options.stats;
|
86
101
|
const hasEFC = newOptionForEnableEFC || prevOptionForEnableEFC;
|
87
102
|
const hashTempalate = enableChunkHash ? '.[chunkhash:20]_' : '';
|
88
103
|
const cssLTRFileNameTempalte = `css/[name]${hashTempalate}${enableRTLSplit ? '.ltr' : ''}.css`;
|
@@ -102,7 +117,7 @@ const getProdPlugins = (options, publicPath = '') => {
|
|
102
117
|
// ignoreOrder: true,
|
103
118
|
filename: cssLTRFileNameTempalte,
|
104
119
|
chunkFilename: cssLTRFileNameTempalte
|
105
|
-
}), new _plugins.ResourceHintsPlugin(), new _plugins.
|
120
|
+
}), new _plugins.ResourceHintsPlugin(options.resourceHints), new _plugins.MinifyPlugin()];
|
106
121
|
|
107
122
|
if (enableRTLSplit) {
|
108
123
|
pluginsArr.push(new _RtlCssPlugin.RtlCssPlugin({
|
@@ -222,9 +237,9 @@ const getProdPlugins = (options, publicPath = '') => {
|
|
222
237
|
if (bundleAnalyze) {
|
223
238
|
pluginsArr.push(new _webpackBundleAnalyzer.BundleAnalyzerPlugin({
|
224
239
|
analyzerMode: 'static',
|
225
|
-
generateStatsFile:
|
240
|
+
generateStatsFile: !enableStats,
|
226
241
|
openAnalyzer: false,
|
227
|
-
statsOptions: {
|
242
|
+
statsOptions: enableStats ? null : {
|
228
243
|
source: false,
|
229
244
|
normal: true,
|
230
245
|
chunks: false,
|
@@ -268,17 +283,29 @@ const getProdPlugins = (options, publicPath = '') => {
|
|
268
283
|
|
269
284
|
if (pluginObject.cssVariableReplacement) {
|
270
285
|
pluginsArr.push(new _VariableConversionCollector.default({
|
271
|
-
cssVariableReplacementConfig
|
286
|
+
cssVariableReplacementConfig,
|
287
|
+
patterns
|
272
288
|
}));
|
273
289
|
}
|
274
290
|
|
275
291
|
if (pluginObject.selectorWeight) {
|
276
292
|
pluginsArr.push(new _SelectorPlugin.default({
|
277
|
-
selectorWeightConfig
|
293
|
+
selectorWeightConfig,
|
294
|
+
exclude: exclude.selectorWeight,
|
295
|
+
patterns
|
278
296
|
}));
|
279
297
|
} // plugins.push(new VariableConversionCollector({}));
|
280
298
|
|
281
299
|
|
300
|
+
customAttributes.enable && pluginsArr.push(new _CustomAttributePlugin.CustomAttributePlugin(customAttributes));
|
301
|
+
customAttributes.enable && pluginsArr.push(new _EfcResourceCleanupPlugin.default(Object.assign({}, customAttributes, {
|
302
|
+
globalCacheObj: context
|
303
|
+
})));
|
304
|
+
enableStats && pluginsArr.push(new _StatsPlugin.default({
|
305
|
+
statsOptions,
|
306
|
+
statsOutputExcludeKeys,
|
307
|
+
statsFileName
|
308
|
+
}));
|
282
309
|
return pluginsArr;
|
283
310
|
};
|
284
311
|
|
@@ -0,0 +1,82 @@
|
|
1
|
+
"use strict";
|
2
|
+
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
4
|
+
value: true
|
5
|
+
});
|
6
|
+
exports.CustomAttributePlugin = void 0;
|
7
|
+
|
8
|
+
var _Template = _interopRequireDefault(require("webpack/lib/Template"));
|
9
|
+
|
10
|
+
var _htmlWebpackInjectAttributesPlugin = _interopRequireDefault(require("html-webpack-inject-attributes-plugin"));
|
11
|
+
|
12
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
13
|
+
|
14
|
+
/* eslint-disable no-use-before-define */
|
15
|
+
class CustomAttributePlugin {
|
16
|
+
constructor(options) {
|
17
|
+
this.options = {
|
18
|
+
attributes: options.attributes,
|
19
|
+
useHTMLAttribute: options.attributes && !options.jsAttributes && !options.cssAttributes && !options.i18nAttributes,
|
20
|
+
jsAttributes: options.jsAttributes || options.attributes || {},
|
21
|
+
cssAttributes: options.cssAttributes || options.attributes || {},
|
22
|
+
i18nAttributes: options.i18nAttributes || options.attributes || {}
|
23
|
+
};
|
24
|
+
}
|
25
|
+
|
26
|
+
addCustomAttributeToDynamicScriptTags(mainTemplate) {
|
27
|
+
const {
|
28
|
+
jsAttributes,
|
29
|
+
cssAttributes,
|
30
|
+
i18nAttributes
|
31
|
+
} = this.options; // NOTE: To add custom Attributes to js Script tags
|
32
|
+
|
33
|
+
mainTemplate.hooks.jsonpScript.tap('CustomAttributePlugin', source => {
|
34
|
+
const str = attributeSetTemplate(jsAttributes, 'script');
|
35
|
+
return _Template.default.asString([source, ...str]);
|
36
|
+
}); // NOTE: To add custom Attributes to css link tags
|
37
|
+
|
38
|
+
mainTemplate.hooks.requireEnsure.tap('CustomAttributePlugin', source => {
|
39
|
+
const str = attributeSetTemplate(cssAttributes, 'linkTag');
|
40
|
+
const replacedStr = source.replace('head.appendChild(linkTag);', `${str.join('')}head.appendChild(linkTag);`); // console.log({ s: source, r: replacedStr });
|
41
|
+
|
42
|
+
return replacedStr;
|
43
|
+
}); // NOTE: To add custom Attributes to i18n split js Script tags
|
44
|
+
|
45
|
+
mainTemplate.hooks.requireEnsure.tap('CustomAttributePlugin', source => {
|
46
|
+
const str = attributeSetTemplate(i18nAttributes, 'scriptTag');
|
47
|
+
const replacedStr = source.replace('document.body.appendChild(scriptTag);', `${str.join('')}document.body.appendChild(scriptTag);`); // console.log({ s: source, r: replacedStr });
|
48
|
+
|
49
|
+
return replacedStr;
|
50
|
+
});
|
51
|
+
}
|
52
|
+
|
53
|
+
apply(compiler) {
|
54
|
+
// NOTE: we not using this, Reason currently this option is only need for EFC,
|
55
|
+
// So it do not needed.
|
56
|
+
const {
|
57
|
+
attributes,
|
58
|
+
useHTMLAttribute
|
59
|
+
} = this.options;
|
60
|
+
useHTMLAttribute && new _htmlWebpackInjectAttributesPlugin.default(attributes).apply(compiler);
|
61
|
+
compiler.hooks.thisCompilation.tap({
|
62
|
+
name: 'CustomAttributePlugin',
|
63
|
+
stage: 1,
|
64
|
+
fn: compilation => {
|
65
|
+
this.addCustomAttributeToDynamicScriptTags(compilation.mainTemplate);
|
66
|
+
}
|
67
|
+
});
|
68
|
+
}
|
69
|
+
|
70
|
+
}
|
71
|
+
|
72
|
+
exports.CustomAttributePlugin = CustomAttributePlugin;
|
73
|
+
|
74
|
+
function attributeSetTemplate(jsAttributes, variableName) {
|
75
|
+
let str = [];
|
76
|
+
Object.keys(jsAttributes).forEach(key => {
|
77
|
+
const val = jsAttributes[key];
|
78
|
+
str.push(`${variableName}.setAttribute(${JSON.stringify(key)}, ${JSON.stringify(val)});`);
|
79
|
+
}); // console.log({ str });
|
80
|
+
|
81
|
+
return str;
|
82
|
+
}
|
@@ -0,0 +1,35 @@
|
|
1
|
+
# CustomAttributePlugin
|
2
|
+
In this plugin we added all dynamic chunks tags (like js script tags , css script tags, i18n split script tags) to extra custom attribute
|
3
|
+
|
4
|
+
## Options
|
5
|
+
|
6
|
+
```json
|
7
|
+
{
|
8
|
+
"name": "some",
|
9
|
+
"react-cli": {
|
10
|
+
"app": {
|
11
|
+
"customAttributes": {// this is the all options
|
12
|
+
"enable": false,
|
13
|
+
"attributes": null,
|
14
|
+
"jsAttributes": null,
|
15
|
+
"cssAttributes": null,
|
16
|
+
"i18nAttributes": null
|
17
|
+
}
|
18
|
+
}
|
19
|
+
}
|
20
|
+
```
|
21
|
+
|
22
|
+
### enable [Boolean]
|
23
|
+
this decides is this plugin or feature needs to be enabled of not.
|
24
|
+
|
25
|
+
|
26
|
+
### attributes [Object]
|
27
|
+
It was object of key value pairs Example Given Option {"data-app-name":"myapp"}
|
28
|
+
Then all dynamically (js script tags , css script tags, i18n split script tags) added tags via webpack
|
29
|
+
|
30
|
+
### jsAttributes [Object]
|
31
|
+
same as [attributes] but only for js script tags
|
32
|
+
### cssAttributes [Object]
|
33
|
+
same as [attributes] but only for css script tags
|
34
|
+
### i18nAttributes [Object]
|
35
|
+
same as [attributes] but only for i18n split script tags
|
package/lib/plugins/EFCPlugin.js
CHANGED
@@ -19,6 +19,8 @@ var _replaceCssDirTemplate = require("./RtlSplitPlugin/replaceCssDirTemplate");
|
|
19
19
|
|
20
20
|
var _EFCTemplatePlugin = _interopRequireDefault(require("./EFCTemplatePlugin"));
|
21
21
|
|
22
|
+
var _logger = require("../logger");
|
23
|
+
|
22
24
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
23
25
|
|
24
26
|
// import { getShortI18nAssets } from './I18nSplitPlugin/utils/hashUtils';
|
@@ -85,18 +87,18 @@ class EFCPlugin {
|
|
85
87
|
getI18nAssetsStr(entryPoint, compilation) {
|
86
88
|
if (!chunkSplitEnable) {
|
87
89
|
let i18nAsstes = {};
|
88
|
-
|
90
|
+
const i18nFiles = Object.keys(compilation.assets).filter(assert => assert.indexOf(`i18n${_path.default.sep}`) !== -1); //hook for i18n url contains i18n/ may cause problem
|
89
91
|
|
90
92
|
i18nAsstes = i18nFiles.reduce((res, i18nFilePath) => {
|
91
|
-
|
92
|
-
|
93
|
+
const fileName = i18nFilePath.replace(`i18n${_path.default.sep}`, '');
|
94
|
+
const splittedFileName = fileName.split('.');
|
93
95
|
res[splittedFileName[0]] = i18nFilePath;
|
94
96
|
return res;
|
95
97
|
}, {});
|
96
98
|
return `[${JSON.stringify(i18nAsstes)}[lang]]`;
|
97
99
|
}
|
98
100
|
|
99
|
-
|
101
|
+
const initalI18nAssets = entryPoint.chunks.filter(chunk => _I18nKeysIdentifer.default.isChunkHasI18n(chunk)).map(chunk => (0, _getI18nFileUrlPathTemplate.getI18nFileUrlPathTemplate)(compilation, chunk, this.i18nFileNameTemplate, '@locale@'));
|
100
102
|
return `${JSON.stringify(initalI18nAssets)}.map(urlpath => urlpath.replace(/@locale@/g, lang))`;
|
101
103
|
}
|
102
104
|
|
@@ -205,8 +207,7 @@ class EFCPlugin {
|
|
205
207
|
apply(compiler) {
|
206
208
|
if (!createSDkFile) {
|
207
209
|
return;
|
208
|
-
}
|
209
|
-
|
210
|
+
}
|
210
211
|
|
211
212
|
if (this.templateFilePath) {
|
212
213
|
new _EFCTemplatePlugin.default({
|
@@ -230,9 +231,8 @@ class EFCPlugin {
|
|
230
231
|
}
|
231
232
|
|
232
233
|
const source = new _webpackSources.RawSource(this.createFileContent(compilation));
|
233
|
-
compilation.assets[outputFile] = source;
|
234
|
-
|
235
|
-
console.log('The EFC embedded code was created successfully..!!!');
|
234
|
+
compilation.assets[outputFile] = source;
|
235
|
+
(0, _logger.messageLogger)('The EFC embedded code was created successfully..!!!');
|
236
236
|
});
|
237
237
|
}
|
238
238
|
|
@@ -19,6 +19,8 @@ var _I18nKeysIdentifer = _interopRequireDefault(require("./I18nSplitPlugin/I18nK
|
|
19
19
|
|
20
20
|
var _replaceCssDirTemplate = require("./RtlSplitPlugin/replaceCssDirTemplate");
|
21
21
|
|
22
|
+
var _logger = require("../logger");
|
23
|
+
|
22
24
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
23
25
|
|
24
26
|
// import { getShortI18nAssets } from './I18nSplitPlugin/utils/hashUtils';
|
@@ -40,9 +42,7 @@ const {
|
|
40
42
|
|
41
43
|
class EFCTemplatePlugin {
|
42
44
|
constructor(options = {}) {
|
43
|
-
|
44
|
-
this.templateFilePath = _path.default.join(process.cwd(), options.templateFilePath); // console.log(' templateFilePath ', this.templateFilePath);
|
45
|
-
|
45
|
+
this.templateFilePath = _path.default.join(process.cwd(), options.templateFilePath);
|
46
46
|
this.i18nFileNameTemplate = options.i18nFileNameTemplate;
|
47
47
|
this.publicPath = options.publicPath; // NOTE: this logic may be needed for i18n splited file name with contenthash cases
|
48
48
|
// this.i18nManifestFileName = options.i18nManifestFileName;
|
@@ -68,18 +68,18 @@ class EFCTemplatePlugin {
|
|
68
68
|
// NOTE: we have used lang variable inside
|
69
69
|
if (!chunkSplitEnable) {
|
70
70
|
let i18nAsstes = {};
|
71
|
-
|
71
|
+
const i18nFiles = Object.keys(compilation.assets).filter(assert => assert.indexOf(`i18n${_path.default.sep}`) !== -1); //hook for i18n url contains i18n/ may cause problem
|
72
72
|
|
73
73
|
i18nAsstes = i18nFiles.reduce((res, i18nFilePath) => {
|
74
|
-
|
75
|
-
|
74
|
+
const fileName = i18nFilePath.replace(`i18n${_path.default.sep}`, '');
|
75
|
+
const splittedFileName = fileName.split('.');
|
76
76
|
res[splittedFileName[0]] = i18nFilePath;
|
77
77
|
return res;
|
78
78
|
}, {});
|
79
79
|
return `[${JSON.stringify(i18nAsstes)}[lang]]`;
|
80
80
|
}
|
81
81
|
|
82
|
-
|
82
|
+
const initalI18nAssets = entryPoint.chunks.filter(chunk => _I18nKeysIdentifer.default.isChunkHasI18n(chunk)).map(chunk => (0, _getI18nFileUrlPathTemplate.getI18nFileUrlPathTemplate)(compilation, chunk, this.i18nFileNameTemplate, '@locale@'));
|
83
83
|
return `${JSON.stringify(initalI18nAssets)}.map(urlpath => urlpath.replace(/@locale@/g, lang))`;
|
84
84
|
}
|
85
85
|
|
@@ -102,7 +102,7 @@ class EFCTemplatePlugin {
|
|
102
102
|
|
103
103
|
const initalI18nAssets = this.getI18nAssetsStr(entryPoint, compilation, '' // i18nJsPath
|
104
104
|
);
|
105
|
-
|
105
|
+
const templateStr = (0, _fs.readFileSync)(this.templateFilePath).toString();
|
106
106
|
return templateStr.replace('((\'getInitalAssets\'))', `function getInitalAssets(assetsType, lang) {
|
107
107
|
if (assetsType === "js") {
|
108
108
|
return ${JSON.stringify(initialJsFiles)}
|
@@ -139,10 +139,8 @@ class EFCTemplatePlugin {
|
|
139
139
|
}
|
140
140
|
|
141
141
|
const source = new _webpackSources.RawSource(this.templateReplacer(entryPoint, compilation));
|
142
|
-
compilation.assets[outputFile] = source;
|
143
|
-
|
144
|
-
|
145
|
-
console.log('The EFC embedded code was created successfully..!!!');
|
142
|
+
compilation.assets[outputFile] = source;
|
143
|
+
(0, _logger.messageLogger)('The EFC embedded code was created successfully..!!!');
|
146
144
|
});
|
147
145
|
}
|
148
146
|
|
@@ -0,0 +1,43 @@
|
|
1
|
+
"use strict";
|
2
|
+
|
3
|
+
const {
|
4
|
+
Template
|
5
|
+
} = require('webpack');
|
6
|
+
|
7
|
+
const plugInName = 'EFCResourceCleanup';
|
8
|
+
module.exports = class EfcResouceCleanupPlugin {
|
9
|
+
constructor(options) {
|
10
|
+
this.options = options;
|
11
|
+
}
|
12
|
+
|
13
|
+
apply(compiler) {
|
14
|
+
compiler.hooks.thisCompilation.tap(plugInName, ({
|
15
|
+
mainTemplate
|
16
|
+
}) => {
|
17
|
+
mainTemplate.hooks.afterStartup.tap(plugInName, source => {
|
18
|
+
const {
|
19
|
+
attributes,
|
20
|
+
globalCacheObj
|
21
|
+
} = this.options;
|
22
|
+
const attributesArr = Object.entries(attributes);
|
23
|
+
const [[attributekey, attributeValue]] = attributesArr;
|
24
|
+
const resourceSelector = `[${attributekey}="${attributeValue}"]`;
|
25
|
+
return Template.asString([source, Template.indent([` window['${globalCacheObj}Jsonp'].unInstall = function() {
|
26
|
+
Object.keys(installedModules).forEach(installedModulesKey => installedModules[installedModulesKey] = null);
|
27
|
+
Object.keys(modules).forEach(moduleKey => modules[moduleKey] = null);
|
28
|
+
`, `
|
29
|
+
installedModules = null;
|
30
|
+
modules = null;
|
31
|
+
__webpack_require__.m = null;
|
32
|
+
__webpack_require__.c = null;
|
33
|
+
|
34
|
+
`, attributekey && attributeValue ? `
|
35
|
+
const addedResources = document.querySelectorAll('${resourceSelector}');
|
36
|
+
addedResources.forEach(addedResource => addedResource.remove());
|
37
|
+
}
|
38
|
+
` : ''])]);
|
39
|
+
});
|
40
|
+
});
|
41
|
+
}
|
42
|
+
|
43
|
+
};
|
@@ -22,7 +22,7 @@ var _getI18nFileUrlPathTemplate = require("./I18nSplitPlugin/utils/getI18nFileUr
|
|
22
22
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
23
23
|
|
24
24
|
let i18nObj = null;
|
25
|
-
|
25
|
+
const options = (0, _utils.getOptions)();
|
26
26
|
|
27
27
|
function newAssign(target, data) {
|
28
28
|
return Object.assign({}, target, data);
|
@@ -43,7 +43,7 @@ class I18NInjectIntoIndexPlugin {
|
|
43
43
|
}
|
44
44
|
|
45
45
|
getI18nFileUrlPath(chunk, compilation) {
|
46
|
-
|
46
|
+
const urlpath = (0, _getI18nFileUrlPathTemplate.getI18nFileUrlPathTemplate)(compilation, chunk, this.i18nFileNameTemplate, this.templateLabel);
|
47
47
|
return (0, _urlConcat.urlConcat)(this.publicPath, urlpath);
|
48
48
|
}
|
49
49
|
|
@@ -81,7 +81,6 @@ class I18NInjectIntoIndexPlugin {
|
|
81
81
|
withI18nSpitHandling(compiler) {
|
82
82
|
compiler.hooks.make.tap('I18NInjectIntoIndexPlugin', compilation => {
|
83
83
|
// let cdns = Object.keys(this.publicPaths);
|
84
|
-
// console.log('compilation.assets', Object.keys(compilation.assets).filter(a => a.includes('i18n')));
|
85
84
|
if (!(0, _hashUtils.hasContentHash)(this.i18nFileNameTemplate)) {
|
86
85
|
this.injectI18nURLsToHTML(compilation);
|
87
86
|
return;
|
@@ -91,7 +90,7 @@ class I18NInjectIntoIndexPlugin {
|
|
91
90
|
// Manipulate the content
|
92
91
|
const i18nManifest = this.getI18nManifest(compilation);
|
93
92
|
const entryPoint = compilation.entrypoints.get(this.entryPointName);
|
94
|
-
|
93
|
+
const i18nAssets = (0, _hashUtils.getShortI18nAssets)(entryPoint.chunks, i18nManifest, this.publicPath);
|
95
94
|
data.html = data.html.replace(new RegExp('<!--I18nInfoToServer(.*?)I18nInfoToServer-->', 'g'), (match, arg) => match.replace(arg, JSON.stringify(i18nAssets))); // Tell webpack to move on
|
96
95
|
|
97
96
|
cb(null, data);
|
@@ -111,11 +110,11 @@ class I18NInjectIntoIndexPlugin {
|
|
111
110
|
compiler.hooks.emit.tap('I18NInjectIntoIndexPlugin', compilation => {
|
112
111
|
// let cdns = Object.keys(this.publicPaths);
|
113
112
|
if (i18nObj === null) {
|
114
|
-
|
113
|
+
const i18nFiles = Object.keys(compilation.assets).filter(assert => assert.indexOf(`i18n${_path.default.sep}`) !== -1); //hook for i18n url contains i18n/ may cause problem
|
115
114
|
|
116
115
|
i18nObj = i18nFiles.reduce((res, next) => {
|
117
|
-
|
118
|
-
|
116
|
+
const fileName = next.replace(`i18n${_path.default.sep}`, '');
|
117
|
+
const splittedFileName = fileName.split('.');
|
119
118
|
/* if (this.isDevelopment) {
|
120
119
|
res[splittedFileName[0]] = `${this.publicPath}/i18n/${fileName}`;
|
121
120
|
} else {
|
@@ -127,10 +126,10 @@ class I18NInjectIntoIndexPlugin {
|
|
127
126
|
}, {});
|
128
127
|
}
|
129
128
|
|
130
|
-
|
129
|
+
const [indexFile] = Object.keys(compilation.assets).filter(filename => /\.html$/g.test(filename));
|
131
130
|
|
132
131
|
if (indexFile) {
|
133
|
-
|
132
|
+
const source = compilation.assets[indexFile].source();
|
134
133
|
compilation.assets[indexFile] = new _webpackSources.RawSource(source.replace(new RegExp('<!--I18nInfoToServer(.*)I18nInfoToServer-->', 'g'), (match, arg) => match.replace(arg, JSON.stringify(i18nObj))));
|
135
134
|
}
|
136
135
|
});
|
@@ -24,10 +24,9 @@ class I18nDebugPlugin {
|
|
24
24
|
compiler.hooks.normalModuleFactory.tap(pluginName, factory => {
|
25
25
|
if (!this.compilationParams || this.compilationParams.normalModuleFactory === factory) {
|
26
26
|
return;
|
27
|
-
}
|
27
|
+
}
|
28
28
|
|
29
|
-
|
30
|
-
let handler = parser => {
|
29
|
+
const handler = parser => {
|
31
30
|
parser.hooks.program.tap(pluginName, (ast, commmets) => {
|
32
31
|
const {
|
33
32
|
module
|
@@ -40,7 +40,7 @@ class I18nKeysIdentifer {
|
|
40
40
|
identifier,
|
41
41
|
i18nKeys
|
42
42
|
}, module.context, 0);
|
43
|
-
module.addDependency(dep);
|
43
|
+
module.addDependency(dep);
|
44
44
|
}
|
45
45
|
|
46
46
|
apply(compiler) {
|
@@ -50,7 +50,7 @@ class I18nKeysIdentifer {
|
|
50
50
|
// and we must define how it import statement look like I18nDependencyTemplate
|
51
51
|
this.defineConfigarationForI18nDependency(compilation); // handler for parser
|
52
52
|
|
53
|
-
|
53
|
+
const handler = parser => {
|
54
54
|
parser.hooks.program.tap(pluginName, (ast, commmets) => {
|
55
55
|
const {
|
56
56
|
module
|
@@ -66,11 +66,6 @@ class I18nKeysIdentifer {
|
|
66
66
|
(0, _utils.collectI18nKeysfromComments)(commmets, this.jsResourceI18nKeys));
|
67
67
|
|
68
68
|
if (i18nKeys.length) {
|
69
|
-
// console.log(
|
70
|
-
// 'i18nKeys.length',
|
71
|
-
// module.resource,
|
72
|
-
// i18nKeys.length < 5 ? i18nKeys : i18nKeys.length
|
73
|
-
// );
|
74
69
|
this.addI18nDependency(module, i18nKeys);
|
75
70
|
}
|
76
71
|
});
|
@@ -11,6 +11,8 @@ var _fs = require("fs");
|
|
11
11
|
|
12
12
|
var _path = require("path");
|
13
13
|
|
14
|
+
var _logger = require("../../../logger");
|
15
|
+
|
14
16
|
function isComment(line) {
|
15
17
|
return line[0] === '#';
|
16
18
|
}
|
@@ -18,7 +20,7 @@ function isComment(line) {
|
|
18
20
|
function getPropertiesAsJSON(filePath) {
|
19
21
|
try {
|
20
22
|
const data = (0, _fs.readFileSync)(filePath);
|
21
|
-
|
23
|
+
const source = data.toString();
|
22
24
|
const i18nObj = {};
|
23
25
|
source.split(/\r?\n\r?/).forEach(fline => {
|
24
26
|
const line = fline.trim();
|
@@ -42,7 +44,7 @@ function getPropertiesAsJSON(filePath) {
|
|
42
44
|
}
|
43
45
|
|
44
46
|
function getLang(file) {
|
45
|
-
|
47
|
+
const underScoreIndex = file.indexOf('_');
|
46
48
|
let language = 'en_US';
|
47
49
|
|
48
50
|
if (underScoreIndex !== -1) {
|
@@ -68,26 +70,24 @@ function getAllI18n({
|
|
68
70
|
const filePath = (0, _path.join)(context, file);
|
69
71
|
|
70
72
|
if (exclude.test(filePath) || !include.test(filePath)) {
|
71
|
-
// console.log('exclude', filePath);
|
72
73
|
return;
|
73
|
-
}
|
74
|
-
|
74
|
+
}
|
75
75
|
|
76
76
|
const i18n = getPropertiesAsJSON(filePath);
|
77
77
|
allLangI18n[getLang(file)] = disableDefault ? i18n : Object.assign({}, jsResourceI18nKeys, i18n);
|
78
78
|
});
|
79
79
|
return allLangI18n;
|
80
80
|
} catch (err) {
|
81
|
-
|
81
|
+
(0, _logger.errorLogger)(err);
|
82
82
|
return {};
|
83
83
|
}
|
84
84
|
}
|
85
85
|
|
86
86
|
function jsonToString(json, keySeperator) {
|
87
87
|
let str = '{';
|
88
|
-
|
88
|
+
const keys = Object.keys(json);
|
89
89
|
keys.forEach((key, i) => {
|
90
|
-
|
90
|
+
const value = json[key];
|
91
91
|
|
92
92
|
if (!value) {
|
93
93
|
return;
|
@@ -11,9 +11,9 @@ var _uglifycss = _interopRequireDefault(require("uglifycss"));
|
|
11
11
|
|
12
12
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
13
13
|
|
14
|
-
class
|
14
|
+
class MinifierPlugin {
|
15
15
|
apply(compiler) {
|
16
|
-
compiler.hooks.emit.tap('
|
16
|
+
compiler.hooks.emit.tap('MinifierPlugin', compilation => {
|
17
17
|
Object.keys(compilation.assets).forEach(filename => {
|
18
18
|
if (/\.css$/.test(filename)) {
|
19
19
|
try {
|
@@ -36,4 +36,4 @@ class UglifyCSSPlugin {
|
|
36
36
|
|
37
37
|
}
|
38
38
|
|
39
|
-
exports.default =
|
39
|
+
exports.default = MinifierPlugin;
|
@@ -13,6 +13,8 @@ var _redis = _interopRequireDefault(require("redis"));
|
|
13
13
|
|
14
14
|
var _utils = require("../utils");
|
15
15
|
|
16
|
+
var _log = require("../utils/log");
|
17
|
+
|
16
18
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
17
19
|
|
18
20
|
let options = (0, _utils.getOptions)();
|
@@ -68,10 +70,10 @@ class reportGeneratePlugin {
|
|
68
70
|
let client = _redis.default.createClient(redisPort, redisHost);
|
69
71
|
|
70
72
|
client.on('connect', () => {
|
71
|
-
(0,
|
73
|
+
(0, _log.log)('Redis client connected');
|
72
74
|
});
|
73
75
|
client.on('error', err => {
|
74
|
-
(0,
|
76
|
+
(0, _log.log)(`Something went wrong ${err}`);
|
75
77
|
});
|
76
78
|
|
77
79
|
if (_fs.default.existsSync(_path.default.resolve(process.cwd(), 'build', 'stats.json'))) {
|
@@ -80,7 +82,7 @@ class reportGeneratePlugin {
|
|
80
82
|
statsJSON = JSON.parse(statsJSON);
|
81
83
|
let finalObj = {};
|
82
84
|
let branchName = branch ? branch : (0, _utils.getCurrentBranch)();
|
83
|
-
(0,
|
85
|
+
(0, _log.log)(branchName);
|
84
86
|
statsJSON.assets.forEach(assetObj => {
|
85
87
|
let nameSplitList = assetObj.name.split('/')[assetObj.name.split('/').length - 1].split('.'); // eslint-disable-line
|
86
88
|
|
@@ -111,7 +113,7 @@ class reportGeneratePlugin {
|
|
111
113
|
};
|
112
114
|
client.get(branchName, (err, reply) => {
|
113
115
|
if (err) {
|
114
|
-
(0,
|
116
|
+
(0, _log.log)(err);
|
115
117
|
} else {
|
116
118
|
reply = JSON.parse(reply); // eslint-disable-line
|
117
119
|
|
@@ -147,7 +149,7 @@ class reportGeneratePlugin {
|
|
147
149
|
throw err;
|
148
150
|
}
|
149
151
|
|
150
|
-
(0,
|
152
|
+
(0, _log.log)('Stats Json generated!');
|
151
153
|
});
|
152
154
|
}
|
153
155
|
});
|
@@ -169,7 +171,7 @@ class reportGeneratePlugin {
|
|
169
171
|
}
|
170
172
|
|
171
173
|
if (err) {
|
172
|
-
(0,
|
174
|
+
(0, _log.log)(err);
|
173
175
|
}
|
174
176
|
});
|
175
177
|
}
|