@zohodesk/react-cli 0.0.1-beta.99 → 0.0.1-betaa.138.2
Sign up to get free protection for your applications and to get access to all the features.
- package/.eslintignore +7 -7
- package/.eslintrc.js +183 -183
- package/CHANGELOG.md +5 -0
- package/README.md +636 -491
- package/bin/cli.js +372 -367
- package/files/eslintrc.js +57 -0
- package/files/prettierrc.js +3 -0
- package/lib/babel/cmjs-plugins-presets.js +16 -9
- package/lib/babel/es-plugins-presets.js +26 -14
- package/lib/common/getEntries.js +31 -22
- package/lib/common/getPublicPathConfig.js +27 -13
- package/lib/common/index.js +21 -25
- package/lib/common/splitChunks.js +62 -53
- package/lib/common/templateParameters.js +10 -8
- package/lib/configs/jest.config.js +15 -25
- package/lib/configs/webpack.component.umd.config.js +31 -37
- package/lib/configs/webpack.css.umd.config.js +44 -47
- package/lib/configs/webpack.dev.config.js +70 -52
- package/lib/configs/webpack.docs.config.js +106 -106
- package/lib/configs/webpack.prod.config.js +95 -75
- package/lib/hooks/docsProptypeHook.js +32 -38
- package/lib/jest/commitedFilesResult.js +103 -74
- package/lib/jest/coverageCollector.js +41 -21
- package/lib/jest/jsonMaker.js +15 -16
- package/lib/jest/preProcessors/cssPreprocessor.js +16 -18
- package/lib/jest/preProcessors/jsPreprocessor.js +3 -5
- package/lib/jest/preProcessors/otherFilesPreprocessor.js +5 -6
- package/lib/jest/result.js +90 -45
- package/lib/jest/run.js +43 -43
- package/lib/jest/setup.js +102 -95
- package/lib/loaderUtils/getCSSLoaders.js +21 -22
- package/lib/loaderUtils/getDevJsLoaders.js +25 -23
- package/lib/loaderUtils/index.js +11 -13
- package/lib/loaders/docsLoader.js +15 -15
- package/lib/loaders/docsPropsLoader.js +14 -17
- package/lib/loaders/fileLoader.js +33 -35
- package/lib/loaders/scriptInstrumentLoader.js +21 -20
- package/lib/loaders/workerLoader.js +136 -0
- package/lib/middlewares/HMRMiddleware.js +54 -45
- package/lib/middlewares/SSTMiddleware.js +8 -5
- package/lib/pluginUtils/getDevPlugins.js +114 -52
- package/lib/pluginUtils/getDocsPlugins.js +25 -29
- package/lib/pluginUtils/getLibraryPlugins.js +8 -10
- package/lib/pluginUtils/getProdPlugins.js +163 -74
- package/lib/pluginUtils/getServerPlugins.js +8 -11
- package/lib/pluginUtils/getUMDCSSPlugins.js +11 -15
- package/lib/pluginUtils/getUMDComponentPlugins.js +11 -15
- package/lib/pluginUtils/index.js +36 -43
- package/lib/plugins/CdnChangePlugin.js +63 -0
- package/lib/plugins/CleanupStatsPlugin.js +18 -32
- package/lib/plugins/CustomAttributePlugin.js +79 -0
- package/lib/plugins/CustomAttributePlugin.md +35 -0
- package/lib/plugins/EFCPlugin.js +185 -0
- package/lib/plugins/I18NInjectIntoIndexPlugin.js +118 -52
- package/lib/plugins/I18nSplitPlugin/I18nDebugPlugin.js +60 -0
- package/lib/plugins/I18nSplitPlugin/I18nDependency.js +44 -0
- package/lib/plugins/I18nSplitPlugin/I18nDownlodLogic.js +266 -0
- package/lib/plugins/I18nSplitPlugin/I18nFilesEmitter.js +183 -0
- package/lib/plugins/I18nSplitPlugin/I18nKeysIdentifer.js +100 -0
- package/lib/plugins/I18nSplitPlugin/I18nSplit.md +86 -0
- package/lib/plugins/I18nSplitPlugin/README.md +25 -0
- package/lib/plugins/I18nSplitPlugin/index.js +185 -0
- package/lib/plugins/I18nSplitPlugin/utils/collectI18nKeys.js +64 -0
- package/lib/plugins/I18nSplitPlugin/utils/getI18nFileUrlPathTemplate.js +13 -0
- package/lib/plugins/I18nSplitPlugin/utils/getI18nKeysFormModules.js +26 -0
- package/lib/plugins/I18nSplitPlugin/utils/hashUtils.js +40 -0
- package/lib/plugins/I18nSplitPlugin/utils/index.js +31 -0
- package/lib/plugins/I18nSplitPlugin/utils/propertiesUtils.js +112 -0
- package/lib/plugins/ManifestPlugin.js +52 -63
- package/lib/plugins/ModuleStatsPlugin.js +83 -173
- package/lib/plugins/OptimizeJSPlugin.js +24 -41
- package/lib/plugins/PublicPathCallbackPlugin.js +42 -116
- package/lib/plugins/PublicPathChangePlugin.js +175 -284
- package/lib/plugins/ReportGeneratePlugin.js +150 -151
- package/lib/plugins/ResourceHintsPlugin.js +53 -35
- package/lib/plugins/ScriptInstrumentPlugin.js +22 -37
- package/lib/plugins/ServiceWorkerPlugin.js +81 -57
- package/lib/plugins/ShadowDOMSupportPlugin.js +153 -234
- package/lib/plugins/SourceMapHookPlugin.js +21 -33
- package/lib/plugins/TPHashMappingPlugin.js +67 -0
- package/lib/plugins/UglifyCSSPlugin.js +23 -30
- package/lib/plugins/UnusedFilesFindPlugin.js +137 -152
- package/lib/plugins/index.js +100 -91
- package/lib/plugins/webpackwatchrunplugin.js +18 -30
- package/lib/postcss-plugins/ExcludeRTLPlugin.js +14 -17
- package/lib/schemas/index.js +336 -81
- package/lib/servers/clusterHubServer.js +22 -26
- package/lib/servers/docsServer.js +3 -5
- package/lib/servers/docsServerCore.js +84 -91
- package/lib/servers/helpServer.js +19 -21
- package/lib/servers/impactServer.js +99 -92
- package/lib/servers/mockserver.js +24 -24
- package/lib/servers/scrServer.js +78 -98
- package/lib/servers/server.js +101 -122
- package/lib/servers/ssServer.js +63 -61
- package/lib/sh/pre-commit.sh +34 -34
- package/lib/sh/reportPublish.sh +45 -46
- package/lib/templates/CoverageScriptTemplate.js +45 -18
- package/lib/templates/WMSTemplate.js +17 -18
- package/lib/templates/linterConstant.js +6 -4
- package/lib/utils/babelPresets.js +12 -5
- package/lib/utils/buildstats.html +148 -148
- package/lib/utils/clean.js +12 -11
- package/lib/utils/copy.js +12 -34
- package/lib/utils/copyTimezones.js +9 -16
- package/lib/utils/createEventStream.js +24 -19
- package/lib/utils/cssClassNameGenerate.js +44 -73
- package/lib/utils/cssURLReplacer.js +60 -54
- package/lib/utils/dependencyPostPublish.js +20 -19
- package/lib/utils/fileUtils.js +66 -54
- package/lib/utils/folderIterator.js +20 -21
- package/lib/utils/getComponents.js +70 -27
- package/lib/utils/getCurrentBranch.js +11 -17
- package/lib/utils/getDependenciesImpactList.js +114 -187
- package/lib/utils/getHash.js +9 -13
- package/lib/utils/getIp.js +9 -9
- package/lib/utils/getOptions.js +26 -29
- package/lib/utils/getServerURL.js +19 -10
- package/lib/utils/index.js +147 -126
- package/lib/utils/init.js +2 -2
- package/lib/utils/initPreCommitHook.js +40 -32
- package/lib/utils/jsonHelper.js +37 -21
- package/lib/utils/lint/addScripts.js +27 -0
- package/lib/utils/lint/checkExistingConfig.js +67 -0
- package/lib/utils/lint/copyConfigs.js +24 -0
- package/lib/utils/lint/index.js +54 -0
- package/lib/utils/lint/lintScripts.js +11 -0
- package/lib/utils/lint/lintSetup.js +31 -0
- package/lib/utils/lint/lintStagedPreCommitHook.js +7 -0
- package/lib/utils/lint/question.js +30 -0
- package/lib/utils/lintReporter.js +70 -56
- package/lib/utils/mailSender.js +12 -27
- package/lib/utils/pullOrigin.js +21 -18
- package/lib/utils/reinstallDependencies.js +76 -85
- package/lib/utils/removeAttributes.js +25 -23
- package/lib/utils/repoClone.js +47 -45
- package/lib/utils/request.js +64 -77
- package/lib/utils/resultSchema.json +73 -73
- package/lib/utils/rtl.js +22 -29
- package/lib/utils/setEnvVariables.js +5 -6
- package/lib/utils/ssTestHack.js +21 -19
- package/lib/utils/switchBranch.js +21 -20
- package/lib/utils/urlConcat.js +22 -0
- package/package.json +141 -136
- 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/index.html +1493 -1493
- 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
@@ -1,60 +1,63 @@
|
|
1
|
-
|
1
|
+
"use strict";
|
2
2
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
4
4
|
value: true
|
5
5
|
});
|
6
|
+
exports.default = void 0;
|
6
7
|
|
7
|
-
var _path = require(
|
8
|
+
var _path = _interopRequireDefault(require("path"));
|
8
9
|
|
9
|
-
var
|
10
|
+
var _fs = _interopRequireDefault(require("fs"));
|
10
11
|
|
11
|
-
var _caseSensitivePathsWebpackPlugin = require(
|
12
|
+
var _caseSensitivePathsWebpackPlugin = _interopRequireDefault(require("case-sensitive-paths-webpack-plugin"));
|
12
13
|
|
13
|
-
var
|
14
|
+
var _lodashWebpackPlugin = _interopRequireDefault(require("lodash-webpack-plugin"));
|
14
15
|
|
15
|
-
var
|
16
|
+
var _miniCssExtractPlugin = _interopRequireDefault(require("mini-css-extract-plugin"));
|
16
17
|
|
17
|
-
var
|
18
|
+
var _htmlWebpackPlugin = _interopRequireDefault(require("html-webpack-plugin"));
|
18
19
|
|
19
|
-
var
|
20
|
+
var _I18nSplitPlugin = _interopRequireDefault(require("../plugins/I18nSplitPlugin"));
|
20
21
|
|
21
|
-
var
|
22
|
+
var _copyWebpackPlugin = _interopRequireDefault(require("copy-webpack-plugin"));
|
22
23
|
|
23
|
-
var
|
24
|
+
var _webpack = _interopRequireDefault(require("webpack"));
|
24
25
|
|
25
|
-
var
|
26
|
+
var _plugins = require("../plugins");
|
26
27
|
|
27
|
-
var
|
28
|
+
var _common = require("../common");
|
28
29
|
|
29
|
-
var
|
30
|
-
|
31
|
-
var _webpack = require('webpack');
|
32
|
-
|
33
|
-
var _webpack2 = _interopRequireDefault(_webpack);
|
34
|
-
|
35
|
-
var _plugins = require('../plugins');
|
36
|
-
|
37
|
-
var _common = require('../common');
|
30
|
+
var _CustomAttributePlugin = require("../plugins/CustomAttributePlugin");
|
38
31
|
|
39
32
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
40
33
|
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
34
|
+
let getDevPlugins = (options, publicPath) => {
|
35
|
+
let {
|
36
|
+
app: {
|
37
|
+
tpFolder,
|
38
|
+
folder,
|
39
|
+
instrumentScript,
|
40
|
+
customAttributes,
|
41
|
+
context,
|
42
|
+
hasEFC: prevOptionForEnableEFC,
|
43
|
+
hasShadowDOM,
|
44
|
+
server: {
|
45
|
+
mode
|
46
|
+
},
|
47
|
+
htmlTemplate: {
|
48
|
+
inject
|
49
|
+
}
|
50
|
+
},
|
51
|
+
efc: {
|
52
|
+
hasEFC: newOptionForEnableEFC,
|
53
|
+
nameScope: efcNameSpace,
|
54
|
+
localeAttr: efcLocaleAttr
|
55
|
+
},
|
56
|
+
i18n,
|
57
|
+
unusedFiles
|
58
|
+
} = options;
|
59
|
+
const hasEFC = newOptionForEnableEFC || prevOptionForEnableEFC;
|
60
|
+
let plugins = [new _plugins.CleanUpStatsPlugin(), new _caseSensitivePathsWebpackPlugin.default(), new _webpack.default.IgnorePlugin(/^\.\/domain$/, /moment$/), new _webpack.default.DefinePlugin({
|
58
61
|
__CLIENT__: true,
|
59
62
|
__TEST__: false,
|
60
63
|
__SERVER__: false,
|
@@ -65,49 +68,108 @@ var getDevPlugins = function getDevPlugins(options, publicPath) {
|
|
65
68
|
'process.env': {
|
66
69
|
NODE_ENV: JSON.stringify(mode === 'dev-no-warn' ? 'production' : 'development')
|
67
70
|
}
|
68
|
-
}), new
|
71
|
+
}), new _miniCssExtractPlugin.default({
|
72
|
+
attributes: customAttributes.cssAttributes,
|
69
73
|
filename: 'css/[name].css',
|
70
|
-
chunkFilename: 'css/[name].css'
|
74
|
+
chunkFilename: 'css/[name].css',
|
75
|
+
ignoreOrder: true
|
71
76
|
}), new _plugins.ResourceHintsPlugin()];
|
72
77
|
|
73
78
|
if (unusedFiles.enable) {
|
74
79
|
plugins.push(new _plugins.UnusedFilesFindPlugin(Object.assign(unusedFiles, {
|
75
|
-
origin:
|
80
|
+
origin: _path.default.join(process.cwd(), folder)
|
76
81
|
})));
|
77
82
|
}
|
78
|
-
|
83
|
+
|
84
|
+
const i18nManifestFileName = 'i18n-manifest.json';
|
85
|
+
/**
|
86
|
+
* NOTE:
|
87
|
+
* this file name ext .i18n.js added
|
88
|
+
* Because, in service worker they maintain cache as file name based
|
89
|
+
* So, to make differce we added .i18n.js ext.
|
90
|
+
*/
|
91
|
+
|
92
|
+
const i18nFileNameTemplate = 'i18n-chunk/[locale]/[name].i18n.js';
|
93
|
+
const i18nPublicPath = publicPath || '';
|
94
|
+
|
95
|
+
if (i18n.chunkSplitEnable) {
|
96
|
+
plugins.push(new _I18nSplitPlugin.default({
|
97
|
+
jsResource: i18n.jsResource,
|
98
|
+
localeVarName: i18n.localeVarName,
|
99
|
+
jsonpFunc: i18n.jsonpFunc,
|
100
|
+
disableDefault: i18n.disableDefault,
|
101
|
+
publicPath: i18nPublicPath,
|
102
|
+
i18nManifestFileName,
|
103
|
+
// template: (object, locale) => `window.loadI18n(${JSON.stringify(object)}, ${JSON.stringify(locale)})`,
|
104
|
+
filenameTemplate: i18nFileNameTemplate,
|
105
|
+
propertiesFolder: i18n.propertiesFolder
|
106
|
+
}));
|
107
|
+
} else {
|
108
|
+
plugins.push(new _copyWebpackPlugin.default({
|
109
|
+
patterns: [{
|
110
|
+
from: `${_path.default.join(process.cwd(), context, 'i18n')}/`,
|
111
|
+
to: './i18n/[name].[ext]',
|
112
|
+
toType: 'template'
|
113
|
+
}]
|
114
|
+
}));
|
115
|
+
}
|
116
|
+
|
117
|
+
tpFolder && plugins.push(new _copyWebpackPlugin.default({
|
118
|
+
patterns: [{
|
119
|
+
from: `${_path.default.join(process.cwd(), context, tpFolder)}/`,
|
120
|
+
to: `./${tpFolder}/`,
|
121
|
+
toType: 'dir'
|
122
|
+
}]
|
123
|
+
}));
|
124
|
+
plugins.push(new _lodashWebpackPlugin.default({
|
79
125
|
collections: true,
|
80
126
|
shorthands: true
|
81
127
|
}));
|
128
|
+
|
82
129
|
if (hasEFC) {
|
83
|
-
plugins.push(new
|
130
|
+
plugins.push(new _htmlWebpackPlugin.default({
|
84
131
|
chunksSortMode: 'none',
|
85
132
|
filename: 'index.html',
|
86
|
-
template:
|
133
|
+
template: _path.default.join(process.cwd(), folder, 'index.html'),
|
87
134
|
excludeChunks: ['efc', 'widget'],
|
88
135
|
templateParameters: _common.templateParameters,
|
89
136
|
scriptLoading: 'defer',
|
90
137
|
inject: inject
|
138
|
+
}));
|
139
|
+
plugins.push(new _plugins.EFCPlugin({
|
140
|
+
isDevelopment: true,
|
141
|
+
i18nManifestFileName,
|
142
|
+
i18nFileNameTemplate,
|
143
|
+
serverUrl: publicPath,
|
144
|
+
entryPointName: 'efc',
|
145
|
+
nameScope: efcNameSpace,
|
146
|
+
localeAttr: efcLocaleAttr // outputFile: 'zohodesk-efc-sdk-latest.js',
|
91
147
|
|
92
148
|
}));
|
93
149
|
} else {
|
94
|
-
plugins.push(new
|
150
|
+
plugins.push(new _htmlWebpackPlugin.default({
|
95
151
|
chunksSortMode: 'none',
|
96
152
|
filename: 'index.html',
|
97
|
-
template:
|
153
|
+
template: _path.default.join(process.cwd(), folder, 'index.html'),
|
98
154
|
templateParameters: _common.templateParameters,
|
99
155
|
scriptLoading: 'defer',
|
100
156
|
inject: inject
|
101
157
|
}));
|
102
158
|
}
|
103
159
|
|
104
|
-
plugins.push(new _plugins.I18NInjectIntoIndexPlugin({
|
105
|
-
|
160
|
+
plugins.push(new _plugins.I18NInjectIntoIndexPlugin({
|
161
|
+
publicPath: i18nPublicPath,
|
162
|
+
isDevelopment: true,
|
163
|
+
templateLabel: i18n.templateLabel || '{{--user-locale}}',
|
164
|
+
i18nFileNameTemplate,
|
165
|
+
i18nManifestFileName,
|
166
|
+
mainChunkName: 'main'
|
167
|
+
}));
|
106
168
|
instrumentScript && plugins.push(new _plugins.ScriptInstrumentPlugin());
|
107
|
-
|
169
|
+
customAttributes.enable && plugins.push(new _CustomAttributePlugin.CustomAttributePlugin(customAttributes));
|
108
170
|
hasShadowDOM && plugins.push(new _plugins.ShadowDOMSupportPlugin());
|
109
|
-
|
110
|
-
return plugins;
|
171
|
+
return plugins.filter(Boolean);
|
111
172
|
};
|
112
173
|
|
113
|
-
|
174
|
+
var _default = getDevPlugins;
|
175
|
+
exports.default = _default;
|
@@ -1,58 +1,54 @@
|
|
1
|
-
|
1
|
+
"use strict";
|
2
2
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
4
4
|
value: true
|
5
5
|
});
|
6
|
+
exports.default = void 0;
|
6
7
|
|
7
|
-
var _caseSensitivePathsWebpackPlugin = require(
|
8
|
+
var _caseSensitivePathsWebpackPlugin = _interopRequireDefault(require("case-sensitive-paths-webpack-plugin"));
|
8
9
|
|
9
|
-
var
|
10
|
+
var _miniCssExtractPlugin = _interopRequireDefault(require("mini-css-extract-plugin"));
|
10
11
|
|
11
|
-
var
|
12
|
+
var _webpack = _interopRequireDefault(require("webpack"));
|
12
13
|
|
13
|
-
var
|
14
|
+
var _path = _interopRequireDefault(require("path"));
|
14
15
|
|
15
|
-
var
|
16
|
-
|
17
|
-
var _webpack2 = _interopRequireDefault(_webpack);
|
18
|
-
|
19
|
-
var _path = require('path');
|
20
|
-
|
21
|
-
var _path2 = _interopRequireDefault(_path);
|
22
|
-
|
23
|
-
var _ModuleStatsPlugin = require('../plugins/ModuleStatsPlugin');
|
24
|
-
|
25
|
-
var _ModuleStatsPlugin2 = _interopRequireDefault(_ModuleStatsPlugin);
|
26
|
-
|
27
|
-
var _plugins = require('../plugins');
|
16
|
+
var _plugins = require("../plugins");
|
28
17
|
|
29
18
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
30
19
|
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
20
|
+
let getDocsPlugins = (isSSTest, options) => {
|
21
|
+
let {
|
22
|
+
app: {
|
23
|
+
folder
|
24
|
+
},
|
25
|
+
unusedFiles
|
26
|
+
} = options;
|
27
|
+
let plugins = [new _plugins.CleanUpStatsPlugin(), new _caseSensitivePathsWebpackPlugin.default(), new _webpack.default.ProvidePlugin({
|
37
28
|
React: 'react'
|
38
|
-
}), new
|
29
|
+
}), new _webpack.default.DefinePlugin({
|
39
30
|
__TEST__: false,
|
40
31
|
__DEVELOPMENT__: true,
|
41
32
|
__DOCS__: true
|
42
|
-
}), new
|
33
|
+
}), new _plugins.ModuleStatsPlugin({
|
34
|
+
filename: 'js/moduleStats.js'
|
35
|
+
}), new _miniCssExtractPlugin.default({
|
43
36
|
filename: 'css/[name].css',
|
44
37
|
chunkFilename: 'css/[name].css'
|
45
|
-
})
|
38
|
+
}), new _plugins.UnusedFilesFindPlugin(Object.assign(unusedFiles, {
|
39
|
+
origin: _path.default.join(process.cwd(), folder)
|
40
|
+
}))].filter(Boolean);
|
46
41
|
|
47
42
|
if (unusedFiles.enable) {
|
48
43
|
plugins.push(new _plugins.UnusedFilesFindPlugin(Object.assign(unusedFiles, {
|
49
44
|
docsFilename: 'Undocsfiles.json',
|
50
45
|
ssTest: true,
|
51
|
-
origin:
|
46
|
+
origin: _path.default.join(process.cwd(), folder)
|
52
47
|
})));
|
53
48
|
}
|
54
49
|
|
55
50
|
return plugins;
|
56
51
|
};
|
57
52
|
|
58
|
-
|
53
|
+
var _default = getDocsPlugins;
|
54
|
+
exports.default = _default;
|
@@ -1,21 +1,18 @@
|
|
1
|
-
|
1
|
+
"use strict";
|
2
2
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
4
4
|
value: true
|
5
5
|
});
|
6
|
+
exports.default = void 0;
|
6
7
|
|
7
|
-
var _caseSensitivePathsWebpackPlugin = require(
|
8
|
+
var _caseSensitivePathsWebpackPlugin = _interopRequireDefault(require("case-sensitive-paths-webpack-plugin"));
|
8
9
|
|
9
|
-
var
|
10
|
-
|
11
|
-
var _webpack = require('webpack');
|
12
|
-
|
13
|
-
var _webpack2 = _interopRequireDefault(_webpack);
|
10
|
+
var _webpack = _interopRequireDefault(require("webpack"));
|
14
11
|
|
15
12
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
16
13
|
|
17
|
-
|
18
|
-
|
14
|
+
let getLibraryPlugins = () => {
|
15
|
+
let plugins = [new _caseSensitivePathsWebpackPlugin.default(), new _webpack.default.DefinePlugin({
|
19
16
|
__TEST__: false,
|
20
17
|
__DEVELOPMENT__: false,
|
21
18
|
__DOCS__: false,
|
@@ -27,4 +24,5 @@ var getLibraryPlugins = function getLibraryPlugins() {
|
|
27
24
|
return plugins;
|
28
25
|
};
|
29
26
|
|
30
|
-
|
27
|
+
var _default = getLibraryPlugins;
|
28
|
+
exports.default = _default;
|
@@ -1,74 +1,78 @@
|
|
1
|
-
|
1
|
+
"use strict";
|
2
2
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
4
4
|
value: true
|
5
5
|
});
|
6
|
+
exports.default = void 0;
|
6
7
|
|
7
|
-
var _path = require(
|
8
|
+
var _path = _interopRequireDefault(require("path"));
|
8
9
|
|
9
|
-
var
|
10
|
+
var _fs = _interopRequireDefault(require("fs"));
|
10
11
|
|
11
|
-
var _webpack = require(
|
12
|
+
var _webpack = _interopRequireDefault(require("webpack"));
|
12
13
|
|
13
|
-
var
|
14
|
+
var _caseSensitivePathsWebpackPlugin = _interopRequireDefault(require("case-sensitive-paths-webpack-plugin"));
|
14
15
|
|
15
|
-
var
|
16
|
+
var _webpackBundleAnalyzer = require("webpack-bundle-analyzer");
|
16
17
|
|
17
|
-
var
|
18
|
+
var _lodashWebpackPlugin = _interopRequireDefault(require("lodash-webpack-plugin"));
|
18
19
|
|
19
|
-
var
|
20
|
+
var _miniCssExtractPlugin = _interopRequireDefault(require("mini-css-extract-plugin"));
|
20
21
|
|
21
|
-
var
|
22
|
+
var _I18nSplitPlugin = _interopRequireDefault(require("../plugins/I18nSplitPlugin"));
|
22
23
|
|
23
|
-
var
|
24
|
+
var _htmlWebpackPlugin = _interopRequireDefault(require("html-webpack-plugin"));
|
24
25
|
|
25
|
-
var
|
26
|
+
var _copyWebpackPlugin = _interopRequireDefault(require("copy-webpack-plugin"));
|
26
27
|
|
27
|
-
var
|
28
|
+
var _plugins = require("../plugins");
|
28
29
|
|
29
|
-
var
|
30
|
+
var _common = require("../common");
|
30
31
|
|
31
|
-
var
|
32
|
-
|
33
|
-
var _copyWebpackPlugin = require('copy-webpack-plugin');
|
34
|
-
|
35
|
-
var _copyWebpackPlugin2 = _interopRequireDefault(_copyWebpackPlugin);
|
36
|
-
|
37
|
-
var _plugins = require('../plugins');
|
38
|
-
|
39
|
-
var _common = require('../common');
|
32
|
+
var _CustomAttributePlugin = require("../plugins/CustomAttributePlugin");
|
40
33
|
|
41
34
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
42
35
|
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
36
|
+
// eslint-disable-next-line no-unused-vars
|
37
|
+
let getProdPlugins = (options, publicPath = '') => {
|
38
|
+
let {
|
39
|
+
enableChunkHash,
|
40
|
+
manifestFileName,
|
41
|
+
bundleAnalyze,
|
42
|
+
optimize,
|
43
|
+
publicPaths,
|
44
|
+
hasEFC: prevOptionForEnableEFC,
|
45
|
+
enableSMapHook,
|
46
|
+
tpFolder,
|
47
|
+
folder,
|
48
|
+
outputFolder,
|
49
|
+
context,
|
50
|
+
enableSMap,
|
51
|
+
server: {
|
52
|
+
mode
|
53
|
+
},
|
54
|
+
hasShadowDOM,
|
55
|
+
resourceHints,
|
56
|
+
serviceWorker,
|
57
|
+
htmlTemplate: {
|
58
|
+
inject
|
59
|
+
},
|
60
|
+
customAttributes,
|
61
|
+
tpHashMapping,
|
62
|
+
cdnMapping
|
63
|
+
} = options.app;
|
64
|
+
const {
|
65
|
+
i18n
|
66
|
+
} = options;
|
67
|
+
const {
|
68
|
+
hasEFC: newOptionForEnableEFC,
|
69
|
+
nameScope: efcNameSpace,
|
70
|
+
localeAttr: efcLocaleAttr
|
71
|
+
} = options.efc;
|
72
|
+
const hasEFC = newOptionForEnableEFC || prevOptionForEnableEFC;
|
73
|
+
let isDevelopment = mode === 'prod' || mode === 'dev' || mode === 'dev-no-warn';
|
65
74
|
enableChunkHash = !isDevelopment && enableChunkHash;
|
66
|
-
|
67
|
-
var plugins = [new _caseSensitivePathsWebpackPlugin2.default(), new _copyWebpackPlugin2.default([{
|
68
|
-
from: _path2.default.join(process.cwd(), context, 'i18n') + '/',
|
69
|
-
to: enableChunkHash ? './i18n/[name].[hash:20]_.[ext]' : './i18n/[name]_.[ext]',
|
70
|
-
toType: 'template'
|
71
|
-
}]), new _webpack2.default.IgnorePlugin(/^\.\/locale$/, /moment$/), new _webpack2.default.DefinePlugin({
|
75
|
+
let plugins = [new _caseSensitivePathsWebpackPlugin.default(), new _webpack.default.IgnorePlugin(/^\.\/locale$/, /moment$/), new _webpack.default.DefinePlugin({
|
72
76
|
__TEST__: false,
|
73
77
|
__DEVELOPMENT__: false,
|
74
78
|
__LOCAL_PRODUCTION__: isDevelopment,
|
@@ -77,44 +81,119 @@ var getProdPlugins = function getProdPlugins(options) {
|
|
77
81
|
NODE_ENV: JSON.stringify('production')
|
78
82
|
},
|
79
83
|
__SERVER__: false
|
80
|
-
}), new
|
84
|
+
}), new _miniCssExtractPlugin.default({
|
81
85
|
filename: enableChunkHash ? './css/[name].[chunkhash:20]_.css' : './css/[name]_.css',
|
82
|
-
chunkFilename: enableChunkHash ? './css/[name].[chunkhash:20]_.css' : './css/[name]_.css'
|
86
|
+
chunkFilename: enableChunkHash ? './css/[name].[chunkhash:20]_.css' : './css/[name]_.css',
|
87
|
+
ignoreOrder: true
|
83
88
|
}), new _plugins.ResourceHintsPlugin(), new _plugins.UglifyCSSPlugin()];
|
89
|
+
const i18nManifestFileName = 'i18n-manifest.json';
|
90
|
+
/**
|
91
|
+
* NOTE:
|
92
|
+
* this file name ext .i18n.js added
|
93
|
+
* Because, in service worker they maintain cache as file name based
|
94
|
+
* So, to make differce we added .i18n.js ext.
|
95
|
+
*/
|
96
|
+
|
97
|
+
const i18nFileNameTemplate = 'i18n-chunk/[locale]/[name].[chunkhash].i18n.js';
|
98
|
+
const i18nPublicPath = Array.isArray(publicPaths) && !cdnMapping.isCdnEnabled ? publicPaths['4'] : ''; // const i18nFileNameTemplate = 'i18n-chunk/[locale]/[name].[contentHash]_.js';
|
99
|
+
// const i18nFileNameTemplate = 'i18n-chunk/[locale]/[name]_.js';
|
100
|
+
|
101
|
+
if (i18n.chunkSplitEnable) {
|
102
|
+
plugins.push(new _I18nSplitPlugin.default({
|
103
|
+
jsResource: i18n.jsResource,
|
104
|
+
localeVarName: i18n.localeVarName,
|
105
|
+
jsonpFunc: i18n.jsonpFunc,
|
106
|
+
disableDefault: i18n.disableDefault,
|
107
|
+
publicPath: i18nPublicPath,
|
108
|
+
i18nManifestFileName,
|
109
|
+
// template: (object, locale) => `window.loadI18n(${JSON.stringify(object)}, ${JSON.stringify(locale)})`,
|
110
|
+
filenameTemplate: i18nFileNameTemplate,
|
111
|
+
propertiesFolder: i18n.propertiesFolder
|
112
|
+
}));
|
113
|
+
} else {
|
114
|
+
plugins.push(new _copyWebpackPlugin.default({
|
115
|
+
patterns: [{
|
116
|
+
from: `${_path.default.join(process.cwd(), context, 'i18n')}/`,
|
117
|
+
to: enableChunkHash ? './i18n/[name].[hash:20]_.[ext]' : './i18n/[name]_.[ext]',
|
118
|
+
toType: 'template'
|
119
|
+
}]
|
120
|
+
}));
|
121
|
+
}
|
122
|
+
|
123
|
+
tpFolder && plugins.push(new _copyWebpackPlugin.default({
|
124
|
+
patterns: [{
|
125
|
+
from: `${_path.default.join(process.cwd(), context, tpFolder)}/`,
|
126
|
+
to: `./${tpFolder}/`,
|
127
|
+
toType: 'dir'
|
128
|
+
}]
|
129
|
+
}));
|
130
|
+
|
84
131
|
if (hasEFC) {
|
85
|
-
plugins.push(new
|
132
|
+
plugins.push(new _htmlWebpackPlugin.default({
|
86
133
|
chunksSortMode: 'none',
|
87
134
|
filename: enableChunkHash ? 'index.[templatehash:20].html' : 'index.html',
|
88
|
-
template:
|
135
|
+
template: _path.default.join(process.cwd(), folder, 'index.html'),
|
89
136
|
excludeChunks: ['efc', 'widget'],
|
90
137
|
minify: false,
|
91
138
|
templateParameters: _common.templateParameters,
|
92
139
|
scriptLoading: 'defer',
|
93
140
|
inject: inject
|
94
141
|
}));
|
142
|
+
plugins.push(new _plugins.EFCPlugin({
|
143
|
+
isDevelopment,
|
144
|
+
serverUrl: publicPath,
|
145
|
+
i18nFileNameTemplate,
|
146
|
+
i18nManifestFileName,
|
147
|
+
entryPointName: 'efc',
|
148
|
+
// outputFile: 'zohodesk-efc-sdk-latest.js',
|
149
|
+
nameScope: efcNameSpace,
|
150
|
+
localeAttr: efcLocaleAttr,
|
151
|
+
cdnVariableName: cdnMapping.isCdnEnabled ? cdnMapping.variableName : null
|
152
|
+
}));
|
95
153
|
} else {
|
96
|
-
plugins.push(new
|
154
|
+
plugins.push(new _htmlWebpackPlugin.default({
|
97
155
|
chunksSortMode: 'none',
|
98
156
|
filename: enableChunkHash ? 'index.[templatehash:20].html' : 'index.html',
|
99
|
-
template:
|
157
|
+
template: _path.default.join(process.cwd(), folder, 'index.html'),
|
100
158
|
minify: false,
|
101
159
|
templateParameters: _common.templateParameters,
|
102
160
|
scriptLoading: 'defer',
|
103
161
|
inject: inject
|
104
162
|
}));
|
105
163
|
}
|
106
|
-
plugins.push(new _plugins.I18NInjectIntoIndexPlugin({ publicPath: publicPath, mode: mode }));
|
107
|
-
if (publicPaths && !isDevelopment) {
|
108
|
-
var callback = publicPaths.callback;
|
109
164
|
|
110
|
-
|
165
|
+
plugins.push(new _plugins.I18NInjectIntoIndexPlugin({
|
166
|
+
// Because we will handle cdn url in CdnChangePlugin
|
167
|
+
publicPath: cdnMapping.isCdnEnabled ? '' : i18nPublicPath,
|
168
|
+
isDevelopment,
|
169
|
+
templateLabel: i18n.templateLabel || '{{--user-locale}}',
|
170
|
+
i18nFileNameTemplate,
|
171
|
+
i18nManifestFileName,
|
172
|
+
mainChunkName: 'main'
|
173
|
+
}));
|
174
|
+
|
175
|
+
if (publicPaths && !isDevelopment && !cdnMapping.isCdnEnabled) {
|
176
|
+
let {
|
177
|
+
callback
|
178
|
+
} = publicPaths;
|
179
|
+
plugins.push(callback ? new _plugins.PublicPathCallbackPlugin({
|
180
|
+
callback
|
181
|
+
}) : new _plugins.PublicPathChangePlugin({
|
182
|
+
publicPaths,
|
183
|
+
resourceHints
|
184
|
+
}));
|
111
185
|
}
|
112
186
|
|
113
|
-
|
187
|
+
if (cdnMapping.isCdnEnabled) {
|
188
|
+
plugins.push(new _plugins.CdnChangePlugin(cdnMapping));
|
189
|
+
}
|
190
|
+
|
191
|
+
plugins.push(new _lodashWebpackPlugin.default({
|
114
192
|
collections: true,
|
115
193
|
shorthands: true
|
116
194
|
}));
|
117
195
|
hasShadowDOM && plugins.push(new _plugins.ShadowDOMSupportPlugin());
|
196
|
+
|
118
197
|
if (!isDevelopment) {
|
119
198
|
enableSMap && enableSMapHook && plugins.push(new _plugins.SourceMapHookPlugin());
|
120
199
|
optimize && plugins.push(new _plugins.OptimizeJSPlugin());
|
@@ -126,6 +205,7 @@ var getProdPlugins = function getProdPlugins(options) {
|
|
126
205
|
plugins.push(new _webpackBundleAnalyzer.BundleAnalyzerPlugin({
|
127
206
|
analyzerMode: 'static',
|
128
207
|
generateStatsFile: true,
|
208
|
+
openAnalyzer: false,
|
129
209
|
statsOptions: {
|
130
210
|
source: false,
|
131
211
|
normal: true,
|
@@ -135,33 +215,42 @@ var getProdPlugins = function getProdPlugins(options) {
|
|
135
215
|
assets: true,
|
136
216
|
assetsSort: 'name'
|
137
217
|
}
|
218
|
+
})); // plugins.push(new ReportGeneratePlugin());
|
219
|
+
}
|
220
|
+
|
221
|
+
if (tpHashMapping && tpHashMapping.length > 0) {
|
222
|
+
plugins.push(new _plugins.TPHashMappingPlugin({
|
223
|
+
fileMappings: tpHashMapping,
|
224
|
+
tpFolder: `${_path.default.join(process.cwd(), context, tpFolder)}/`
|
138
225
|
}));
|
139
|
-
// plugins.push(new ReportGeneratePlugin());
|
140
226
|
}
|
141
227
|
}
|
142
228
|
|
143
229
|
if (!isDevelopment && serviceWorker.enableSw) {
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
|
149
|
-
|
150
|
-
replaceText = _serviceWorker$replac === undefined ? '@@' : _serviceWorker$replac;
|
230
|
+
let {
|
231
|
+
filePath,
|
232
|
+
fileName = 'sw.js',
|
233
|
+
exitPath = '/',
|
234
|
+
replaceText = '@@'
|
235
|
+
} = serviceWorker;
|
151
236
|
|
152
237
|
if (!filePath) {
|
153
238
|
throw new Error('File Path required for service worker plugin');
|
154
239
|
}
|
240
|
+
|
155
241
|
plugins.push(new _plugins.ServiceWorkerPlugin({
|
156
|
-
filePath:
|
242
|
+
filePath: _path.default.join(process.cwd(), filePath),
|
243
|
+
i18nFileNameTemplate,
|
157
244
|
fileName: fileName,
|
158
|
-
exitPath:
|
159
|
-
replaceText
|
160
|
-
publicPaths
|
245
|
+
exitPath: _path.default.join(outputFolder, exitPath),
|
246
|
+
replaceText,
|
247
|
+
publicPaths
|
161
248
|
}));
|
162
249
|
}
|
163
250
|
|
251
|
+
customAttributes.enable && plugins.push(new _CustomAttributePlugin.CustomAttributePlugin(customAttributes));
|
164
252
|
return plugins;
|
165
253
|
};
|
166
254
|
|
167
|
-
|
255
|
+
var _default = getProdPlugins;
|
256
|
+
exports.default = _default;
|