@zohodesk/react-cli 0.0.1-test.148.2 → 1.0.0-exp.1
Sign up to get free protection for your applications and to get access to all the features.
- package/.eslintignore +7 -7
- package/.eslintrc.js +180 -183
- package/.prettierrc +6 -0
- package/{CHANGELOG.md → CHANGELOG-fz.md} +0 -0
- package/Changelog.md +1019 -0
- package/README.md +1161 -678
- package/bin/cli.js +483 -392
- package/docs/CustomChunks.md +26 -0
- package/docs/DevServerPort.md +39 -0
- package/docs/DevStart.md +18 -0
- package/docs/HoverActive.md +12 -0
- package/docs/InstallNode.md +28 -0
- package/docs/SelectorWeight.md +6 -0
- package/docs/TODOS.md +10 -0
- package/docs/ValueReplacer.md +60 -0
- package/docs/VariableConversion.md +724 -0
- package/docs/warnings_while_install.txt +35 -0
- package/files/eslintrc.js +62 -62
- package/files/prettierrc.js +3 -3
- package/lib/common/getEntries.js +9 -6
- package/lib/common/index.js +6 -6
- package/lib/common/splitChunks.js +60 -12
- package/lib/common/sslcertUpdater.js +59 -0
- package/lib/common/testPattern.js +69 -0
- package/lib/common/valueReplacer.js +55 -0
- package/lib/configs/jest.config.js +18 -8
- package/lib/configs/libAlias.js +38 -0
- package/lib/configs/resolvers.js +40 -0
- package/lib/configs/webpack.css.umd.config.js +4 -4
- package/lib/configs/webpack.dev.config.js +59 -54
- package/lib/configs/webpack.docs.config.js +74 -59
- package/lib/configs/webpack.docs1.config.js +122 -0
- package/lib/configs/webpack.impact.config.js +54 -50
- package/lib/configs/webpack.prod.config.js +72 -47
- package/lib/constants.js +31 -0
- package/lib/hooks/docsEntry.js +18 -0
- package/lib/jest/preProcessors/cssPreprocessor.js +16 -7
- package/lib/loaderUtils/configsAssetsLoaders.js +117 -0
- package/lib/loaderUtils/getCSSLoaders.js +89 -21
- package/lib/loaderUtils/index.js +4 -4
- package/lib/loaderUtils/windowsModification.js +11 -0
- package/lib/loaders/fileBountryLoader.js +17 -0
- package/lib/loaders/scriptInstrumentLoader.js +2 -2
- package/lib/loaders/selectorMappingLoader.js +75 -0
- package/lib/loaders/workerLoader.js +9 -9
- package/lib/pluginUtils/configHtmlWebpackPlugins.js +60 -0
- package/lib/pluginUtils/getDevPlugins.js +71 -45
- package/lib/pluginUtils/getDocsPlugins.js +21 -10
- package/lib/pluginUtils/getLibraryImactPlugins.js +23 -0
- package/lib/pluginUtils/getProdPlugins.js +75 -58
- package/lib/pluginUtils/index.js +12 -12
- package/lib/plugins/CdnChangePlugin.js +16 -2
- package/lib/plugins/EFCPlugin.js +52 -20
- package/lib/plugins/EFCPlugin.md +6 -0
- package/lib/plugins/EFCTemplatePlugin.js +151 -0
- package/lib/plugins/I18NInjectIntoIndexPlugin.js +4 -4
- package/lib/plugins/I18nSplitPlugin/I18nDownlodLogic.js +38 -38
- package/lib/plugins/I18nSplitPlugin/I18nFilesEmitter.js +30 -30
- package/lib/plugins/I18nSplitPlugin/I18nKeysIdentifer.js +8 -8
- package/lib/plugins/I18nSplitPlugin/I18nSplit.md +95 -86
- package/lib/plugins/I18nSplitPlugin/README.md +25 -25
- package/lib/plugins/I18nSplitPlugin/index.js +57 -57
- package/lib/plugins/I18nSplitPlugin/utils/hashUtils.js +2 -2
- package/lib/plugins/I18nSplitPlugin/utils/propertiesUtils.js +1 -1
- package/lib/plugins/ManifestPlugin.js +8 -0
- package/lib/plugins/RequireVariablePublicPlugin.js +30 -0
- package/lib/plugins/ResourceHintsPlugin.js +17 -17
- package/lib/plugins/RtlSplitPlugin/RtlCssPlugin.js +11 -7
- package/lib/plugins/RtlSplitPlugin/RtrSplit.md +30 -0
- package/lib/plugins/SelectorPlugin.js +97 -0
- package/lib/plugins/ServiceWorkerPlugin.js +13 -9
- package/lib/plugins/SourceMapHookPlugin.js +9 -3
- package/lib/plugins/TPHashMappingPlugin.js +4 -4
- package/lib/plugins/VariableConversionCollector.js +352 -0
- package/lib/plugins/composeCommonPlugin.js +30 -0
- package/lib/plugins/index.js +36 -36
- package/lib/plugins/libraryImpactPlugin.js +14 -2
- package/lib/postcss-plugins/{ExcludeRTLPlugin.js → ExcludePlugin.js} +1 -1
- package/lib/postcss-plugins/RTLSplitPlugin.js +36 -32
- package/lib/postcss-plugins/ValueReplacer.js +46 -0
- package/lib/postcss-plugins/__test__/hoverActivePlugin.spec.js +22 -0
- package/lib/postcss-plugins/__test__/test1Input.css +39 -0
- package/lib/postcss-plugins/__test__/test1Output.css +39 -0
- package/lib/postcss-plugins/hoverActivePlugin.js +389 -0
- package/lib/postcss-plugins/variableModificationPlugin/ErrorHandler.js +60 -0
- package/lib/postcss-plugins/variableModificationPlugin/index.js +307 -0
- package/lib/postcss-plugins/variableModifier.js +244 -0
- package/lib/schemas/index.js +174 -11
- package/lib/servers/devBuild.js +102 -0
- package/lib/servers/docsServerCore.js +16 -18
- package/lib/servers/getCliPath.js +28 -0
- package/lib/servers/httpsOptions.js +49 -0
- package/lib/servers/nowatchserver.js +206 -0
- package/lib/servers/server.js +114 -82
- package/lib/sh/pre-commit.sh +34 -34
- package/lib/sh/reportPublish.sh +45 -45
- package/lib/templates/linterConstant.js +1 -1
- package/lib/utils/buildstats.html +148 -148
- package/lib/utils/cssClassNameGenerate.js +9 -2
- package/lib/utils/cssURLReplacer.js +30 -43
- package/lib/utils/getCurrentBranch.js +1 -1
- package/lib/utils/getDependenciesImpactList.js +14 -12
- package/lib/utils/getFileType.js +49 -0
- package/lib/utils/getOptions.js +118 -10
- package/lib/utils/index.js +44 -20
- package/lib/utils/jsonHelper.js +12 -3
- package/lib/utils/reinstallDependencies.js +1 -1
- package/lib/utils/repoClone.js +16 -4
- package/lib/utils/resultSchema.json +73 -73
- package/lib/utils/rtl.js +19 -2
- package/lib/utils/useExitCleanup.js +55 -0
- package/npm8.md +9 -0
- package/package.json +121 -142
- package/postpublish.js +8 -0
- package/result.json +1 -0
- 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/a.html +13 -0
- 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/docsEntry.js +14 -0
- package/templates/docs/docsRoot.js +3 -0
- package/templates/docs/impactReportTemplate.html +154 -154
- package/templates/docs/index.html +1501 -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
- package/unittest/index.html +37 -0
- package/cert/cert.pem +0 -105
- package/cert/key.pem +0 -30
@@ -21,22 +21,26 @@ var _miniCssExtractPlugin = _interopRequireDefault(require("mini-css-extract-plu
|
|
21
21
|
|
22
22
|
var _I18nSplitPlugin = _interopRequireDefault(require("../plugins/I18nSplitPlugin"));
|
23
23
|
|
24
|
-
var _htmlWebpackPlugin = _interopRequireDefault(require("html-webpack-plugin"));
|
25
|
-
|
26
24
|
var _copyWebpackPlugin = _interopRequireDefault(require("copy-webpack-plugin"));
|
27
25
|
|
28
|
-
var
|
26
|
+
var _VariableConversionCollector = _interopRequireDefault(require("../plugins/VariableConversionCollector"));
|
27
|
+
|
28
|
+
var _SelectorPlugin = _interopRequireDefault(require("../plugins/SelectorPlugin"));
|
29
29
|
|
30
|
-
var
|
30
|
+
var _plugins = require("../plugins");
|
31
31
|
|
32
32
|
var _RtlCssPlugin = require("../plugins/RtlSplitPlugin/RtlCssPlugin");
|
33
33
|
|
34
|
+
var _configHtmlWebpackPlugins = require("./configHtmlWebpackPlugins");
|
35
|
+
|
34
36
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
35
37
|
|
36
38
|
// eslint-disable-next-line no-unused-vars
|
37
|
-
|
39
|
+
const getProdPlugins = (options, publicPath = '') => {
|
38
40
|
let {
|
39
|
-
enableChunkHash
|
41
|
+
enableChunkHash
|
42
|
+
} = options.app;
|
43
|
+
const {
|
40
44
|
manifestFileName,
|
41
45
|
bundleAnalyze,
|
42
46
|
optimize,
|
@@ -45,6 +49,7 @@ let getProdPlugins = (options, publicPath = '') => {
|
|
45
49
|
enableSMapHook,
|
46
50
|
tpFolder,
|
47
51
|
folder,
|
52
|
+
mainEntryHtmlFile,
|
48
53
|
outputFolder,
|
49
54
|
context,
|
50
55
|
enableSMap,
|
@@ -52,14 +57,21 @@ let getProdPlugins = (options, publicPath = '') => {
|
|
52
57
|
mode
|
53
58
|
},
|
54
59
|
hasShadowDOM,
|
60
|
+
cssVariableReplacementConfig,
|
61
|
+
plugins: pluginObject,
|
62
|
+
// exclude,
|
63
|
+
selectorWeightConfig,
|
55
64
|
resourceHints,
|
56
65
|
serviceWorker,
|
57
|
-
htmlTemplate
|
58
|
-
inject
|
59
|
-
},
|
66
|
+
htmlTemplate,
|
60
67
|
tpHashMapping,
|
61
|
-
cdnMapping
|
68
|
+
cdnMapping,
|
69
|
+
crossorigin
|
62
70
|
} = options.app;
|
71
|
+
const {
|
72
|
+
inject,
|
73
|
+
minify: minifyHtmlOptions
|
74
|
+
} = htmlTemplate;
|
63
75
|
const {
|
64
76
|
i18n
|
65
77
|
} = options;
|
@@ -69,15 +81,16 @@ let getProdPlugins = (options, publicPath = '') => {
|
|
69
81
|
const {
|
70
82
|
hasEFC: newOptionForEnableEFC,
|
71
83
|
nameScope: efcNameSpace,
|
84
|
+
templateFilePath,
|
72
85
|
localeAttr: efcLocaleAttr
|
73
86
|
} = options.efc;
|
74
87
|
const hasEFC = newOptionForEnableEFC || prevOptionForEnableEFC;
|
75
88
|
const hashTempalate = enableChunkHash ? '.[chunkhash:20]_' : '';
|
76
|
-
const cssLTRFileNameTempalte = `css/[name]${hashTempalate}.ltr.css`;
|
89
|
+
const cssLTRFileNameTempalte = `css/[name]${hashTempalate}${enableRTLSplit ? '.ltr' : ''}.css`;
|
77
90
|
const cssRTLFileNameTempalte = `css/[name]${hashTempalate}.rtl.css`;
|
78
|
-
|
91
|
+
const isDevelopment = mode === 'prod' || mode === 'dev' || mode === 'dev-no-warn';
|
79
92
|
enableChunkHash = !isDevelopment && enableChunkHash;
|
80
|
-
|
93
|
+
const pluginsArr = [new _caseSensitivePathsWebpackPlugin.default(), new _webpack.default.IgnorePlugin(/^\.\/locale$/, /moment$/), new _webpack.default.DefinePlugin({
|
81
94
|
__TEST__: false,
|
82
95
|
__DEVELOPMENT__: false,
|
83
96
|
__LOCAL_PRODUCTION__: isDevelopment,
|
@@ -93,8 +106,9 @@ let getProdPlugins = (options, publicPath = '') => {
|
|
93
106
|
}), new _plugins.ResourceHintsPlugin(), new _plugins.UglifyCSSPlugin()];
|
94
107
|
|
95
108
|
if (enableRTLSplit) {
|
96
|
-
|
109
|
+
pluginsArr.push(new _RtlCssPlugin.RtlCssPlugin({
|
97
110
|
templateLabel: options.css.templateLabel,
|
111
|
+
disableMiniFiySelector: options.css.disableMiniFiySelector,
|
98
112
|
dirVarName: options.css.dirVarName,
|
99
113
|
// config: {},
|
100
114
|
// sourcemap: true,
|
@@ -103,11 +117,11 @@ let getProdPlugins = (options, publicPath = '') => {
|
|
103
117
|
}
|
104
118
|
|
105
119
|
const i18nManifestFileName = 'i18n-manifest.json';
|
106
|
-
/**
|
107
|
-
* NOTE:
|
108
|
-
* this file name ext .i18n.js added
|
109
|
-
* Because, in service worker they maintain cache as file name based
|
110
|
-
* So, to make differce we added .i18n.js ext.
|
120
|
+
/**
|
121
|
+
* NOTE:
|
122
|
+
* this file name ext .i18n.js added
|
123
|
+
* Because, in service worker they maintain cache as file name based
|
124
|
+
* So, to make differce we added .i18n.js ext.
|
111
125
|
*/
|
112
126
|
|
113
127
|
const i18nFileNameTemplate = 'i18n-chunk/[locale]/[name].[chunkhash].i18n.js';
|
@@ -115,7 +129,7 @@ let getProdPlugins = (options, publicPath = '') => {
|
|
115
129
|
// const i18nFileNameTemplate = 'i18n-chunk/[locale]/[name]_.js';
|
116
130
|
|
117
131
|
if (i18n.chunkSplitEnable) {
|
118
|
-
|
132
|
+
pluginsArr.push(new _I18nSplitPlugin.default({
|
119
133
|
jsResource: i18n.jsResource,
|
120
134
|
localeVarName: i18n.localeVarName,
|
121
135
|
jsonpFunc: i18n.jsonpFunc,
|
@@ -127,10 +141,10 @@ let getProdPlugins = (options, publicPath = '') => {
|
|
127
141
|
propertiesFolder: i18n.propertiesFolder
|
128
142
|
}));
|
129
143
|
} else {
|
130
|
-
|
144
|
+
const i18nPath = _path.default.join(process.cwd(), context, 'i18n');
|
131
145
|
|
132
146
|
if (_fs.default.existsSync(i18nPath)) {
|
133
|
-
|
147
|
+
pluginsArr.push(new _copyWebpackPlugin.default([{
|
134
148
|
from: `${i18nPath}/`,
|
135
149
|
to: enableChunkHash ? './i18n/[name].[hash:20]_.[ext]' : './i18n/[name]_.[ext]',
|
136
150
|
toType: 'template'
|
@@ -138,27 +152,27 @@ let getProdPlugins = (options, publicPath = '') => {
|
|
138
152
|
}
|
139
153
|
}
|
140
154
|
|
141
|
-
tpFolder &&
|
155
|
+
tpFolder && pluginsArr.push(new _copyWebpackPlugin.default([{
|
142
156
|
from: `${_path.default.join(process.cwd(), context, tpFolder)}/`,
|
143
157
|
to: `./${tpFolder}/`,
|
144
158
|
toType: 'dir'
|
145
159
|
}]));
|
160
|
+
(0, _configHtmlWebpackPlugins.configHtmlWebpackPlugins)(pluginsArr, {
|
161
|
+
enableChunkHash,
|
162
|
+
folder,
|
163
|
+
mainEntryHtmlFile,
|
164
|
+
inject,
|
165
|
+
minify: minifyHtmlOptions,
|
166
|
+
crossorigin,
|
167
|
+
hasEFC
|
168
|
+
});
|
146
169
|
|
147
170
|
if (hasEFC) {
|
148
|
-
|
149
|
-
chunksSortMode: 'none',
|
150
|
-
filename: enableChunkHash ? 'index.[templatehash:20].html' : 'index.html',
|
151
|
-
template: _path.default.join(process.cwd(), folder, 'index.html'),
|
152
|
-
excludeChunks: ['efc', 'widget'],
|
153
|
-
minify: false,
|
154
|
-
templateParameters: _common.templateParameters,
|
155
|
-
scriptLoading: 'defer',
|
156
|
-
inject: inject
|
157
|
-
}));
|
158
|
-
plugins.push(new _plugins.EFCPlugin({
|
171
|
+
pluginsArr.push(new _plugins.EFCPlugin({
|
159
172
|
isDevelopment,
|
160
173
|
serverUrl: publicPath,
|
161
174
|
i18nFileNameTemplate,
|
175
|
+
templateFilePath,
|
162
176
|
i18nManifestFileName,
|
163
177
|
entryPointName: 'efc',
|
164
178
|
// outputFile: 'zohodesk-efc-sdk-latest.js',
|
@@ -166,19 +180,9 @@ let getProdPlugins = (options, publicPath = '') => {
|
|
166
180
|
localeAttr: efcLocaleAttr,
|
167
181
|
cdnVariableName: cdnMapping.isCdnEnabled ? cdnMapping.variableName : null
|
168
182
|
}));
|
169
|
-
} else {
|
170
|
-
plugins.push(new _htmlWebpackPlugin.default({
|
171
|
-
chunksSortMode: 'none',
|
172
|
-
filename: enableChunkHash ? 'index.[templatehash:20].html' : 'index.html',
|
173
|
-
template: _path.default.join(process.cwd(), folder, 'index.html'),
|
174
|
-
minify: false,
|
175
|
-
templateParameters: _common.templateParameters,
|
176
|
-
scriptLoading: 'defer',
|
177
|
-
inject: inject
|
178
|
-
}));
|
179
183
|
}
|
180
184
|
|
181
|
-
|
185
|
+
pluginsArr.push(new _plugins.I18NInjectIntoIndexPlugin({
|
182
186
|
// Because we will handle cdn url in CdnChangePlugin
|
183
187
|
publicPath: cdnMapping.isCdnEnabled ? '' : i18nPublicPath,
|
184
188
|
isDevelopment,
|
@@ -189,10 +193,10 @@ let getProdPlugins = (options, publicPath = '') => {
|
|
189
193
|
}));
|
190
194
|
|
191
195
|
if (publicPaths && !isDevelopment && !cdnMapping.isCdnEnabled) {
|
192
|
-
|
196
|
+
const {
|
193
197
|
callback
|
194
198
|
} = publicPaths;
|
195
|
-
|
199
|
+
pluginsArr.push(callback ? new _plugins.PublicPathCallbackPlugin({
|
196
200
|
callback
|
197
201
|
}) : new _plugins.PublicPathChangePlugin({
|
198
202
|
publicPaths,
|
@@ -201,24 +205,24 @@ let getProdPlugins = (options, publicPath = '') => {
|
|
201
205
|
}
|
202
206
|
|
203
207
|
if (cdnMapping.isCdnEnabled) {
|
204
|
-
|
208
|
+
pluginsArr.push(new _plugins.CdnChangePlugin(cdnMapping));
|
205
209
|
}
|
206
210
|
|
207
|
-
|
211
|
+
pluginsArr.push(new _lodashWebpackPlugin.default({
|
208
212
|
collections: true,
|
209
213
|
shorthands: true
|
210
214
|
}));
|
211
|
-
hasShadowDOM &&
|
215
|
+
hasShadowDOM && pluginsArr.push(new _plugins.ShadowDOMSupportPlugin());
|
212
216
|
|
213
217
|
if (!isDevelopment) {
|
214
|
-
enableSMap && enableSMapHook &&
|
215
|
-
optimize &&
|
216
|
-
|
218
|
+
enableSMap && enableSMapHook && pluginsArr.push(new _plugins.SourceMapHookPlugin());
|
219
|
+
optimize && pluginsArr.push(new _plugins.OptimizeJSPlugin());
|
220
|
+
pluginsArr.push(new _plugins.ManifestPlugin({
|
217
221
|
fileName: manifestFileName
|
218
222
|
}));
|
219
223
|
|
220
224
|
if (bundleAnalyze) {
|
221
|
-
|
225
|
+
pluginsArr.push(new _webpackBundleAnalyzer.BundleAnalyzerPlugin({
|
222
226
|
analyzerMode: 'static',
|
223
227
|
generateStatsFile: true,
|
224
228
|
openAnalyzer: false,
|
@@ -235,7 +239,7 @@ let getProdPlugins = (options, publicPath = '') => {
|
|
235
239
|
}
|
236
240
|
|
237
241
|
if (tpHashMapping && tpHashMapping.length > 0) {
|
238
|
-
|
242
|
+
pluginsArr.push(new _plugins.TPHashMappingPlugin({
|
239
243
|
fileMappings: tpHashMapping,
|
240
244
|
tpFolder: `${_path.default.join(process.cwd(), context, tpFolder)}/`
|
241
245
|
}));
|
@@ -243,7 +247,7 @@ let getProdPlugins = (options, publicPath = '') => {
|
|
243
247
|
}
|
244
248
|
|
245
249
|
if (!isDevelopment && serviceWorker.enableSw) {
|
246
|
-
|
250
|
+
const {
|
247
251
|
filePath,
|
248
252
|
fileName = 'sw.js',
|
249
253
|
exitPath = '/',
|
@@ -254,7 +258,7 @@ let getProdPlugins = (options, publicPath = '') => {
|
|
254
258
|
throw new Error('File Path required for service worker plugin');
|
255
259
|
}
|
256
260
|
|
257
|
-
|
261
|
+
pluginsArr.push(new _plugins.ServiceWorkerPlugin({
|
258
262
|
filePath: _path.default.join(process.cwd(), filePath),
|
259
263
|
i18nFileNameTemplate,
|
260
264
|
fileName: fileName,
|
@@ -264,7 +268,20 @@ let getProdPlugins = (options, publicPath = '') => {
|
|
264
268
|
}));
|
265
269
|
}
|
266
270
|
|
267
|
-
|
271
|
+
if (pluginObject.cssVariableReplacement) {
|
272
|
+
pluginsArr.push(new _VariableConversionCollector.default({
|
273
|
+
cssVariableReplacementConfig
|
274
|
+
}));
|
275
|
+
}
|
276
|
+
|
277
|
+
if (pluginObject.selectorWeight) {
|
278
|
+
pluginsArr.push(new _SelectorPlugin.default({
|
279
|
+
selectorWeightConfig
|
280
|
+
}));
|
281
|
+
} // plugins.push(new VariableConversionCollector({}));
|
282
|
+
|
283
|
+
|
284
|
+
return pluginsArr;
|
268
285
|
};
|
269
286
|
|
270
287
|
var _default = getProdPlugins;
|
package/lib/pluginUtils/index.js
CHANGED
@@ -9,34 +9,28 @@ Object.defineProperty(exports, "getDevPlugins", {
|
|
9
9
|
return _getDevPlugins.default;
|
10
10
|
}
|
11
11
|
});
|
12
|
-
Object.defineProperty(exports, "getProdPlugins", {
|
13
|
-
enumerable: true,
|
14
|
-
get: function () {
|
15
|
-
return _getProdPlugins.default;
|
16
|
-
}
|
17
|
-
});
|
18
12
|
Object.defineProperty(exports, "getDocsPlugins", {
|
19
13
|
enumerable: true,
|
20
14
|
get: function () {
|
21
15
|
return _getDocsPlugins.default;
|
22
16
|
}
|
23
17
|
});
|
24
|
-
Object.defineProperty(exports, "
|
18
|
+
Object.defineProperty(exports, "getLibraryPlugins", {
|
25
19
|
enumerable: true,
|
26
20
|
get: function () {
|
27
|
-
return
|
21
|
+
return _getLibraryPlugins.default;
|
28
22
|
}
|
29
23
|
});
|
30
|
-
Object.defineProperty(exports, "
|
24
|
+
Object.defineProperty(exports, "getProdPlugins", {
|
31
25
|
enumerable: true,
|
32
26
|
get: function () {
|
33
|
-
return
|
27
|
+
return _getProdPlugins.default;
|
34
28
|
}
|
35
29
|
});
|
36
|
-
Object.defineProperty(exports, "
|
30
|
+
Object.defineProperty(exports, "getServerPlugins", {
|
37
31
|
enumerable: true,
|
38
32
|
get: function () {
|
39
|
-
return
|
33
|
+
return _getServerPlugins.default;
|
40
34
|
}
|
41
35
|
});
|
42
36
|
Object.defineProperty(exports, "getUMDCSSPlugins", {
|
@@ -45,6 +39,12 @@ Object.defineProperty(exports, "getUMDCSSPlugins", {
|
|
45
39
|
return _getUMDCSSPlugins.default;
|
46
40
|
}
|
47
41
|
});
|
42
|
+
Object.defineProperty(exports, "getUMDComponentPlugins", {
|
43
|
+
enumerable: true,
|
44
|
+
get: function () {
|
45
|
+
return _getUMDComponentPlugins.default;
|
46
|
+
}
|
47
|
+
});
|
48
48
|
|
49
49
|
var _getDevPlugins = _interopRequireDefault(require("./getDevPlugins"));
|
50
50
|
|
@@ -7,11 +7,19 @@ exports.default = void 0;
|
|
7
7
|
|
8
8
|
var _htmlWebpackPlugin = _interopRequireDefault(require("html-webpack-plugin"));
|
9
9
|
|
10
|
+
var _utils = require("../utils");
|
11
|
+
|
10
12
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
11
13
|
|
12
14
|
const MODULE_TYPE = 'css/mini-extract';
|
13
15
|
|
14
|
-
const isI18nFile = url => url.endsWith(
|
16
|
+
const isI18nFile = url => url.endsWith('.i18n.js');
|
17
|
+
|
18
|
+
const {
|
19
|
+
app: {
|
20
|
+
enableSMap
|
21
|
+
}
|
22
|
+
} = (0, _utils.getOptions)();
|
15
23
|
|
16
24
|
class CdnChangePlugin {
|
17
25
|
constructor(options) {
|
@@ -50,7 +58,13 @@ class CdnChangePlugin {
|
|
50
58
|
_htmlWebpackPlugin.default.getHooks(compilation).beforeAssetTagGeneration.tapAsync('CdnChangePlugin', (data, cb) => {
|
51
59
|
data.assets = Object.assign({}, data.assets, {
|
52
60
|
css: data.assets.css.map(css => `${this.cssTemplate}${css}`),
|
53
|
-
js: data.assets.js.map(js =>
|
61
|
+
js: data.assets.js.map(js => {
|
62
|
+
if (enableSMap && !isI18nFile(js)) {
|
63
|
+
js = js.replace('js/', `{{--js-smap}}js/`); //eslint-disable-line
|
64
|
+
}
|
65
|
+
|
66
|
+
return `${isI18nFile(js) ? this.i18nTemplate : this.jsTemplate}${js}`;
|
67
|
+
})
|
54
68
|
});
|
55
69
|
cb(null, data);
|
56
70
|
});
|
package/lib/plugins/EFCPlugin.js
CHANGED
@@ -17,6 +17,8 @@ var _I18nKeysIdentifer = _interopRequireDefault(require("./I18nSplitPlugin/I18nK
|
|
17
17
|
|
18
18
|
var _replaceCssDirTemplate = require("./RtlSplitPlugin/replaceCssDirTemplate");
|
19
19
|
|
20
|
+
var _EFCTemplatePlugin = _interopRequireDefault(require("./EFCTemplatePlugin"));
|
21
|
+
|
20
22
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
21
23
|
|
22
24
|
// import { getShortI18nAssets } from './I18nSplitPlugin/utils/hashUtils';
|
@@ -34,24 +36,28 @@ const {
|
|
34
36
|
efc: efcOptios
|
35
37
|
} = cliOptions;
|
36
38
|
const {
|
37
|
-
createSDkFile
|
39
|
+
createSDkFile,
|
40
|
+
cdnStatement
|
38
41
|
} = efcOptios;
|
39
42
|
|
40
43
|
class EFCPlugin {
|
41
44
|
constructor(options = {}) {
|
42
45
|
this.isDevelopment = options.isDevelopment;
|
46
|
+
this.templateFilePath = options.templateFilePath;
|
43
47
|
this.serverUrl = options.serverUrl;
|
44
|
-
this.i18nFileNameTemplate = options.i18nFileNameTemplate; // this
|
45
|
-
|
46
|
-
|
48
|
+
this.i18nFileNameTemplate = options.i18nFileNameTemplate; // NOTE: this logic may be needed for i18n splited file name with contenthash cases
|
49
|
+
// this.i18nManifestFileName = options.i18nManifestFileName;
|
50
|
+
// IMPORTANT: here we mergeing optionds from pacakge.json and options via constructor
|
51
|
+
// So when debugging consider this as well
|
47
52
|
|
53
|
+
this.options = Object.assign({}, efcOptios, options);
|
48
54
|
this.options.entryPointName = options.entryPointName || 'efc';
|
49
55
|
this.options.outputFile = efcOptios.outputFile.replace('[version]', efcOptios.version);
|
50
56
|
this.options.nameScope = options.nameScope || 'EFComponents';
|
51
|
-
const localeAttr = this.options.localeAttr || 'efc-locale';
|
52
|
-
const cssDirAttr = this.options.cssDirAttr || 'efc-
|
53
|
-
const localeDefaultValue = this.options.
|
54
|
-
const cssDirDefaultValue = this.options.
|
57
|
+
const localeAttr = this.options.localeAttr || 'data-efc-locale';
|
58
|
+
const cssDirAttr = this.options.cssDirAttr || 'data-efc-dir';
|
59
|
+
const localeDefaultValue = this.options.localeDefaultValue || 'en_US';
|
60
|
+
const cssDirDefaultValue = this.options.cssDirDefaultValue || 'ltr';
|
55
61
|
this.options.localeStatement = options.localeStatement || // Statment 1: return langEle && langEle.getAttribute('${localeAttr}') || 'en_US';
|
56
62
|
// Statment 2: return langEle ? langEle.getAttribute('${localeAttr}') : 'en_US';
|
57
63
|
// We are using statement1 not statment2,
|
@@ -64,7 +70,7 @@ class EFCPlugin {
|
|
64
70
|
let dirEle = document.querySelector('[${cssDirAttr}]');
|
65
71
|
return dirEle && dirEle.getAttribute('${cssDirAttr}') || '${cssDirDefaultValue}';
|
66
72
|
})();`;
|
67
|
-
} // NOTE: this logic may be needed for contenthash cases
|
73
|
+
} // NOTE: this logic may be needed for i18n splited file name with contenthash cases
|
68
74
|
// getI18nManifest(compilation) {
|
69
75
|
// const i18nManifestFile =
|
70
76
|
// compilation.assets[this.options.i18nManifestFileName];
|
@@ -123,20 +129,35 @@ class EFCPlugin {
|
|
123
129
|
${enableRTLSplit ? `const cssDir = ${cssDirStatement};` : ''}
|
124
130
|
const prod = !${this.isDevelopment};
|
125
131
|
let cdnVariableName = "${cdnVariableName}";
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
+
|
133
|
+
function getAssetUrl(ext) {
|
134
|
+
${cdnStatement ? `
|
135
|
+
return (() => {
|
136
|
+
let fu = (${cdnStatement});
|
137
|
+
return typeof fu === "function" ? fu(ext) : fu;
|
138
|
+
})();` : ''}
|
139
|
+
|
140
|
+
${publicPaths.callback ? `return (${publicPaths.callback})(ext)` : ''}
|
141
|
+
|
142
|
+
let assetURLs = {
|
143
|
+
//hook
|
144
|
+
js: ${JSON.stringify(jsPath || serverUrl)},
|
145
|
+
css: ${JSON.stringify(cssPath || serverUrl)},
|
146
|
+
i18n: ${JSON.stringify(i18nJsPath || serverUrl)}
|
147
|
+
};
|
148
|
+
|
149
|
+
return assetURLs[ext];
|
150
|
+
|
151
|
+
}
|
152
|
+
|
132
153
|
|
133
154
|
window.desk_urls={}
|
134
|
-
window.desk_urls.staticDomain = 'https:' +
|
155
|
+
window.desk_urls.staticDomain = 'https:' + getAssetUrl('js') + '/';
|
135
156
|
if (prod && cdnVariableName) {
|
136
|
-
window["${cdnVariableName}"] = 'https:' +
|
157
|
+
window["${cdnVariableName}"] = 'https:' + getAssetUrl('css') + '/';
|
137
158
|
}
|
138
159
|
|
139
|
-
let initalI18nAssets = ${initalI18nAssets}
|
160
|
+
let initalI18nAssets = ${initalI18nAssets};
|
140
161
|
let initialAssets = initalI18nAssets.concat(${JSON.stringify(enableRTLSplit ? filteredInitialFiles.map(filePath => (0, _replaceCssDirTemplate.replaceCssDirTemplate)(filePath, cssDirTemplate)) : filteredInitialFiles)});
|
141
162
|
|
142
163
|
let loadAsset = (id, type, url) => {
|
@@ -148,12 +169,12 @@ class EFCPlugin {
|
|
148
169
|
switch(type) {
|
149
170
|
case 'script':
|
150
171
|
case 'i18n':
|
151
|
-
el.src = (type === 'i18n'?
|
172
|
+
el.src = (type === 'i18n'? getAssetUrl('i18n') : getAssetUrl('js'))+'/'+url
|
152
173
|
el.defer = 'defer';
|
153
174
|
document.body.appendChild(el);
|
154
175
|
break;
|
155
176
|
case 'link':
|
156
|
-
el.href =
|
177
|
+
el.href = getAssetUrl('css')+'/'+url${enableRTLSplit ? `.replace(${JSON.stringify(cssDirTemplate)}, cssDir)` : ''}
|
157
178
|
el.rel = 'stylesheet';
|
158
179
|
document.head.appendChild(el);
|
159
180
|
break;
|
@@ -184,6 +205,17 @@ class EFCPlugin {
|
|
184
205
|
apply(compiler) {
|
185
206
|
if (!createSDkFile) {
|
186
207
|
return;
|
208
|
+
} //console.log('this.templateFilePath', this.templateFilePath, this.options);
|
209
|
+
|
210
|
+
|
211
|
+
if (this.templateFilePath) {
|
212
|
+
new _EFCTemplatePlugin.default({
|
213
|
+
templateFilePath: this.templateFilePath,
|
214
|
+
publicPath: this.serverUrl,
|
215
|
+
i18nFileNameTemplate: this.i18nFileNameTemplate,
|
216
|
+
entryPointName: this.options.entryPointName
|
217
|
+
}).apply(compiler);
|
218
|
+
return;
|
187
219
|
}
|
188
220
|
|
189
221
|
compiler.hooks.emit.tap('EFCPlugin', compilation => {
|
@@ -0,0 +1,151 @@
|
|
1
|
+
"use strict";
|
2
|
+
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
4
|
+
value: true
|
5
|
+
});
|
6
|
+
exports.default = void 0;
|
7
|
+
|
8
|
+
var _webpackSources = require("webpack-sources");
|
9
|
+
|
10
|
+
var _utils = require("../utils");
|
11
|
+
|
12
|
+
var _path = _interopRequireDefault(require("path"));
|
13
|
+
|
14
|
+
var _fs = require("fs");
|
15
|
+
|
16
|
+
var _getI18nFileUrlPathTemplate = require("./I18nSplitPlugin/utils/getI18nFileUrlPathTemplate");
|
17
|
+
|
18
|
+
var _I18nKeysIdentifer = _interopRequireDefault(require("./I18nSplitPlugin/I18nKeysIdentifer"));
|
19
|
+
|
20
|
+
var _replaceCssDirTemplate = require("./RtlSplitPlugin/replaceCssDirTemplate");
|
21
|
+
|
22
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
23
|
+
|
24
|
+
// import { getShortI18nAssets } from './I18nSplitPlugin/utils/hashUtils';
|
25
|
+
const cliOptions = (0, _utils.getOptions)();
|
26
|
+
const {
|
27
|
+
i18n: {
|
28
|
+
chunkSplitEnable
|
29
|
+
},
|
30
|
+
css: {
|
31
|
+
enableRTLSplit
|
32
|
+
},
|
33
|
+
efc: efcOptios
|
34
|
+
} = cliOptions;
|
35
|
+
const {
|
36
|
+
createSDkFile
|
37
|
+
} = efcOptios; // for smap relate changes
|
38
|
+
// CdnChangePlugin
|
39
|
+
// SourceMapHookPlugin
|
40
|
+
|
41
|
+
class EFCTemplatePlugin {
|
42
|
+
constructor(options = {}) {
|
43
|
+
// console.log(' templateFilePath ', process.cwd(), options.templateFilePath, templateFilePath);
|
44
|
+
this.templateFilePath = _path.default.join(process.cwd(), options.templateFilePath); // console.log(' templateFilePath ', this.templateFilePath);
|
45
|
+
|
46
|
+
this.i18nFileNameTemplate = options.i18nFileNameTemplate;
|
47
|
+
this.publicPath = options.publicPath; // NOTE: this logic may be needed for i18n splited file name with contenthash cases
|
48
|
+
// this.i18nManifestFileName = options.i18nManifestFileName;
|
49
|
+
// IMPORTANT: here we mergeing optionds from pacakge.json and options via constructor
|
50
|
+
// So when debugging consider this as well
|
51
|
+
// this.options = Object.assign({}, efcOptios, options);
|
52
|
+
|
53
|
+
this.entryPointName = options.entryPointName || 'efc';
|
54
|
+
this.outputFile = efcOptios.outputFile.replace('[version]', efcOptios.version);
|
55
|
+
} // NOTE: this logic may be needed for i18n splited file name with contenthash cases
|
56
|
+
// getI18nManifest(compilation) {
|
57
|
+
// const i18nManifestFile =
|
58
|
+
// compilation.assets[this.options.i18nManifestFileName];
|
59
|
+
// if (i18nManifestFile) {
|
60
|
+
// const manifest = JSON.parse(i18nManifestFile.source());
|
61
|
+
// return manifest;
|
62
|
+
// }
|
63
|
+
// return {};
|
64
|
+
// }
|
65
|
+
|
66
|
+
|
67
|
+
getI18nAssetsStr(entryPoint, compilation) {
|
68
|
+
// NOTE: we have used lang variable inside
|
69
|
+
if (!chunkSplitEnable) {
|
70
|
+
let i18nAsstes = {};
|
71
|
+
let i18nFiles = Object.keys(compilation.assets).filter(assert => assert.indexOf(`i18n${_path.default.sep}`) !== -1); //hook for i18n url contains i18n/ may cause problem
|
72
|
+
|
73
|
+
i18nAsstes = i18nFiles.reduce((res, i18nFilePath) => {
|
74
|
+
let fileName = i18nFilePath.replace(`i18n${_path.default.sep}`, '');
|
75
|
+
let splittedFileName = fileName.split('.');
|
76
|
+
res[splittedFileName[0]] = i18nFilePath;
|
77
|
+
return res;
|
78
|
+
}, {});
|
79
|
+
return `[${JSON.stringify(i18nAsstes)}[lang]]`;
|
80
|
+
}
|
81
|
+
|
82
|
+
let initalI18nAssets = entryPoint.chunks.filter(chunk => _I18nKeysIdentifer.default.isChunkHasI18n(chunk)).map(chunk => (0, _getI18nFileUrlPathTemplate.getI18nFileUrlPathTemplate)(compilation, chunk, this.i18nFileNameTemplate, '@locale@'));
|
83
|
+
return `${JSON.stringify(initalI18nAssets)}.map(urlpath => urlpath.replace(/@locale@/g, lang))`;
|
84
|
+
}
|
85
|
+
|
86
|
+
templateReplacer(entryPoint, compilation) {
|
87
|
+
const cssDirTemplate = '@dir@'; // const i18nManifest = this.getI18nManifest(compilation);
|
88
|
+
|
89
|
+
const initialFiles = entryPoint.getFiles();
|
90
|
+
const filteredInitialFiles = initialFiles.filter(file => /\.(css|js)$/.test(file));
|
91
|
+
const initialJsFiles = filteredInitialFiles.filter(file => /\.js$/.test(file));
|
92
|
+
let initialCssFiles = filteredInitialFiles.filter(file => /\.css$/.test(file));
|
93
|
+
|
94
|
+
if (enableRTLSplit) {
|
95
|
+
initialCssFiles = initialCssFiles.map(filePath => (0, _replaceCssDirTemplate.replaceCssDirTemplate)(filePath, cssDirTemplate));
|
96
|
+
} // const i18nAssets = getShortI18nAssets(
|
97
|
+
// entryPoint.chunks,
|
98
|
+
// i18nManifest,
|
99
|
+
// '' // i18nJsPath
|
100
|
+
// );
|
101
|
+
|
102
|
+
|
103
|
+
const initalI18nAssets = this.getI18nAssetsStr(entryPoint, compilation, '' // i18nJsPath
|
104
|
+
);
|
105
|
+
let templateStr = (0, _fs.readFileSync)(this.templateFilePath).toString();
|
106
|
+
return templateStr.replace('((\'getInitalAssets\'))', `function getInitalAssets(assetsType, lang) {
|
107
|
+
if (assetsType === "js") {
|
108
|
+
return ${JSON.stringify(initialJsFiles)}
|
109
|
+
}
|
110
|
+
if (assetsType === "css") {
|
111
|
+
return ${JSON.stringify(initialCssFiles)}
|
112
|
+
}
|
113
|
+
if (assetsType === "i18n") {
|
114
|
+
return ${initalI18nAssets};
|
115
|
+
}
|
116
|
+
return [];
|
117
|
+
}`).replace('((\'@dir@\'))', '\'@dir@\'').replace('((\'publicPath\'))', this.publicPath).replace('((\'@locale@\'))', '\'@locale@\'');
|
118
|
+
}
|
119
|
+
|
120
|
+
apply(compiler) {
|
121
|
+
if (!createSDkFile) {
|
122
|
+
return;
|
123
|
+
}
|
124
|
+
|
125
|
+
compiler.hooks.emit.tap('EFCTemplatePlugin', compilation => {
|
126
|
+
const {
|
127
|
+
entryPointName,
|
128
|
+
outputFile
|
129
|
+
} = this;
|
130
|
+
const entryPoint = compilation.entrypoints.get(entryPointName);
|
131
|
+
|
132
|
+
if (!entryPoint) {
|
133
|
+
return;
|
134
|
+
}
|
135
|
+
|
136
|
+
if (!(0, _fs.existsSync)(this.templateFilePath)) {
|
137
|
+
console.error(`EFC Template file not exists ${this.templateFilePath}`);
|
138
|
+
return;
|
139
|
+
}
|
140
|
+
|
141
|
+
const source = new _webpackSources.RawSource(this.templateReplacer(entryPoint, compilation));
|
142
|
+
compilation.assets[outputFile] = source; // console.log('EFCTemplatePlugin working');
|
143
|
+
// eslint-disable-next-line no-console
|
144
|
+
|
145
|
+
console.log('The EFC embedded code was created successfully..!!!');
|
146
|
+
});
|
147
|
+
}
|
148
|
+
|
149
|
+
}
|
150
|
+
|
151
|
+
exports.default = EFCTemplatePlugin;
|