@zohodesk/react-cli 0.0.1-beta.174 → 0.0.1-beta.176
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.eslintignore +7 -7
- package/.eslintrc.js +180 -180
- package/.prettierrc +6 -6
- package/README.md +1018 -1003
- package/bin/cli.js +482 -482
- package/cert/Tsicsezwild-22-23.crt +37 -37
- package/cert/Tsicsezwild-22-23.key +27 -27
- package/docs/CustomChunks.md +26 -26
- package/docs/DevStart.md +18 -18
- package/docs/HoverActive.md +12 -12
- package/docs/InstallNode.md +28 -28
- package/docs/SelectorWeight.md +6 -0
- package/docs/TODOS.md +10 -10
- package/docs/ValueReplacer.md +60 -60
- package/docs/VariableConversion.md +710 -678
- package/docs/warnings_while_install.txt +35 -35
- package/files/eslintrc.js +62 -62
- package/files/prettierrc.js +3 -3
- package/lib/configs/webpack.css.umd.config.js +4 -4
- package/lib/configs/webpack.dev.config.js +23 -2
- package/lib/configs/webpack.docs.config.js +13 -1
- package/lib/configs/webpack.impact.config.js +13 -1
- package/lib/configs/webpack.prod.config.js +23 -2
- package/lib/loaderUtils/configsAssetsLoaders.js +33 -33
- package/lib/loaderUtils/getCSSLoaders.js +24 -21
- package/lib/loaderUtils/windowsModification.js +11 -0
- package/lib/loaders/workerLoader.js +9 -9
- package/lib/pluginUtils/configHtmlWebpackPlugins.js +59 -0
- package/lib/pluginUtils/getDevPlugins.js +54 -52
- package/lib/pluginUtils/getProdPlugins.js +66 -63
- package/lib/plugins/EFCPlugin.md +6 -6
- package/lib/plugins/I18NInjectIntoIndexPlugin.js +4 -4
- package/lib/plugins/I18nSplitPlugin/I18nDownlodLogic.js +38 -38
- package/lib/plugins/I18nSplitPlugin/I18nFilesEmitter.js +30 -30
- package/lib/plugins/I18nSplitPlugin/I18nKeysIdentifer.js +8 -8
- package/lib/plugins/I18nSplitPlugin/I18nSplit.md +95 -95
- package/lib/plugins/I18nSplitPlugin/README.md +25 -25
- package/lib/plugins/I18nSplitPlugin/index.js +57 -57
- package/lib/plugins/ResourceHintsPlugin.js +17 -17
- package/lib/plugins/RtlSplitPlugin/RtlCssPlugin.js +6 -6
- package/lib/plugins/RtlSplitPlugin/RtrSplit.md +30 -30
- package/lib/plugins/SelectorPlugin.js +97 -0
- package/lib/plugins/ServiceWorkerPlugin.js +9 -9
- package/lib/plugins/TPHashMappingPlugin.js +4 -4
- package/lib/plugins/VariableConversionCollector.js +252 -0
- package/lib/plugins/composeCommonPlugin.js +30 -0
- package/lib/postcss-plugins/RTLSplitPlugin.js +10 -10
- package/lib/postcss-plugins/__test__/test1Input.css +38 -38
- package/lib/postcss-plugins/__test__/test1Output.css +38 -38
- package/lib/postcss-plugins/hoverActivePlugin.js +13 -9
- package/lib/postcss-plugins/variableModificationPlugin/ErrorHandler.js +35 -14
- package/lib/postcss-plugins/variableModificationPlugin/index.js +202 -143
- package/lib/schemas/index.js +20 -8
- package/lib/sh/pre-commit.sh +34 -34
- package/lib/sh/reportPublish.sh +45 -45
- package/lib/utils/buildstats.html +148 -148
- package/lib/utils/resultSchema.json +73 -73
- package/npm8.md +9 -9
- package/package.json +146 -146
- package/postpublish.js +6 -6
- package/templates/app/.eslintrc.js +140 -140
- package/templates/app/README.md +12 -12
- package/templates/app/app/index.html +24 -24
- package/templates/app/app/properties/ApplicationResources_en_US.properties +1 -1
- package/templates/app/app/properties/i18nkeys.json +3 -3
- package/templates/app/docs/all.html +69 -69
- package/templates/app/mockapi/index.js +18 -18
- package/templates/app/package.json +37 -37
- package/templates/app/src/actions/SampleActions/index.js +37 -37
- package/templates/app/src/actions/index.js +65 -65
- package/templates/app/src/appUrls.js +19 -19
- package/templates/app/src/components/Alert/Alert.js +134 -134
- package/templates/app/src/components/Alert/Alert.module.css +79 -79
- package/templates/app/src/components/FreezeLayer/FreezeLayer.css +37 -37
- package/templates/app/src/components/FreezeLayer/FreezeLayer.js +84 -84
- package/templates/app/src/components/Sample/Sample.module.css +11 -11
- package/templates/app/src/components/Sample/SampleList.js +61 -61
- package/templates/app/src/components/Slider/Slider.css +41 -41
- package/templates/app/src/components/Slider/Slider.js +55 -55
- package/templates/app/src/containers/AlertContainer/index.js +15 -15
- package/templates/app/src/containers/AppContainer/index.js +96 -96
- package/templates/app/src/containers/AppContainer/index.module.css +27 -27
- package/templates/app/src/containers/CustomMatch/index.js +65 -65
- package/templates/app/src/containers/DevTools/index.js +10 -10
- package/templates/app/src/containers/Header/index.js +67 -67
- package/templates/app/src/containers/Header/index.module.css +43 -43
- package/templates/app/src/containers/Redirect/index.js +63 -63
- package/templates/app/src/containers/Redirector/index.js +47 -47
- package/templates/app/src/containers/SampleListContainer/ListContainer.js +42 -42
- package/templates/app/src/containers/SampleListContainer/ListContainer.module.css +3 -3
- package/templates/app/src/historyChange.js +5 -5
- package/templates/app/src/index.html +10 -10
- package/templates/app/src/index.js +24 -24
- package/templates/app/src/middleware/PromiseMiddleware.js +59 -59
- package/templates/app/src/reducers/alertData.js +11 -11
- package/templates/app/src/reducers/index.js +6 -6
- package/templates/app/src/reducers/samples.js +19 -19
- package/templates/app/src/store/configureStore.dev.js +51 -51
- package/templates/app/src/store/configureStore.js +5 -5
- package/templates/app/src/store/configureStore.prod.js +26 -26
- package/templates/app/src/util/Common.js +5 -5
- package/templates/app/src/util/RequestAPI.js +132 -132
- package/templates/docs/all.html +249 -249
- package/templates/docs/component.html +178 -178
- package/templates/docs/components.html +221 -221
- package/templates/docs/css/b.min.css +6 -6
- package/templates/docs/css/component.css +42 -42
- package/templates/docs/css/componentTest.css +6 -6
- package/templates/docs/css/hopscotch.css +585 -585
- package/templates/docs/css/style.css +1022 -1022
- package/templates/docs/impactReportTemplate.html +154 -154
- package/templates/docs/index.html +1501 -1501
- package/templates/docs/js/active-line.js +72 -72
- package/templates/docs/js/b.min.js +7 -7
- package/templates/docs/js/codemirror.js +9680 -9680
- package/templates/docs/js/designTokens.js +334 -334
- package/templates/docs/js/j.min.js +4 -4
- package/templates/docs/js/javascript.js +874 -874
- package/templates/docs/js/matchbrackets.js +145 -145
@@ -15,10 +15,6 @@ var _lodashWebpackPlugin = _interopRequireDefault(require("lodash-webpack-plugin
|
|
15
15
|
|
16
16
|
var _miniCssExtractPlugin = _interopRequireDefault(require("mini-css-extract-plugin"));
|
17
17
|
|
18
|
-
var _htmlWebpackPlugin = _interopRequireDefault(require("html-webpack-plugin"));
|
19
|
-
|
20
|
-
var _htmlWebpackInjectAttributesPlugin = _interopRequireDefault(require("html-webpack-inject-attributes-plugin"));
|
21
|
-
|
22
18
|
var _I18nSplitPlugin = _interopRequireDefault(require("../plugins/I18nSplitPlugin"));
|
23
19
|
|
24
20
|
var _RequireVariablePublicPlugin = _interopRequireDefault(require("../plugins/RequireVariablePublicPlugin"));
|
@@ -29,14 +25,19 @@ var _webpack = _interopRequireDefault(require("webpack"));
|
|
29
25
|
|
30
26
|
var _plugins = require("../plugins");
|
31
27
|
|
32
|
-
var _common = require("../common");
|
33
|
-
|
34
28
|
var _RtlCssPlugin = require("../plugins/RtlSplitPlugin/RtlCssPlugin");
|
35
29
|
|
30
|
+
var _VariableConversionCollector = _interopRequireDefault(require("../plugins/VariableConversionCollector"));
|
31
|
+
|
32
|
+
var _SelectorPlugin = _interopRequireDefault(require("../plugins/SelectorPlugin"));
|
33
|
+
|
34
|
+
var _configHtmlWebpackPlugins = require("./configHtmlWebpackPlugins");
|
35
|
+
|
36
36
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
37
37
|
|
38
|
-
|
39
|
-
|
38
|
+
// import { windowsModification } from '../loaderUtils/windowsModification';
|
39
|
+
const getDevPlugins = (options, publicPath) => {
|
40
|
+
const {
|
40
41
|
app: {
|
41
42
|
tpFolder,
|
42
43
|
folder,
|
@@ -45,6 +46,10 @@ let getDevPlugins = (options, publicPath) => {
|
|
45
46
|
context,
|
46
47
|
hasEFC: prevOptionForEnableEFC,
|
47
48
|
hasShadowDOM,
|
49
|
+
cssVariableReplacementConfig,
|
50
|
+
plugins: pluginObject,
|
51
|
+
// exclude,
|
52
|
+
selectorWeightConfig,
|
48
53
|
server: {
|
49
54
|
mode
|
50
55
|
},
|
@@ -67,8 +72,9 @@ let getDevPlugins = (options, publicPath) => {
|
|
67
72
|
} = options;
|
68
73
|
const hasEFC = newOptionForEnableEFC || prevOptionForEnableEFC;
|
69
74
|
const cssLTRFileNameTempalte = enableRTLSplit ? 'css/[name].ltr.css' : 'css/[name].css';
|
70
|
-
const cssRTLFileNameTempalte = 'css/[name].rtl.css';
|
71
|
-
|
75
|
+
const cssRTLFileNameTempalte = 'css/[name].rtl.css'; // const selectorWeightLocal = windowsModification(exclude.selectorWeight);
|
76
|
+
|
77
|
+
const pluginsArr = [new _plugins.CleanUpStatsPlugin(), new _caseSensitivePathsWebpackPlugin.default(), new _webpack.default.IgnorePlugin(/^\.\/domain$/, /moment$/), new _webpack.default.DefinePlugin({
|
72
78
|
__CLIENT__: true,
|
73
79
|
__TEST__: false,
|
74
80
|
__SERVER__: false,
|
@@ -86,7 +92,7 @@ let getDevPlugins = (options, publicPath) => {
|
|
86
92
|
}), new _plugins.ResourceHintsPlugin()];
|
87
93
|
|
88
94
|
if (enableRTLSplit) {
|
89
|
-
|
95
|
+
pluginsArr.push(new _RtlCssPlugin.RtlCssPlugin({
|
90
96
|
templateLabel: options.css.templateLabel,
|
91
97
|
dirVarName: options.css.dirVarName,
|
92
98
|
disableMiniFiySelector: options.css.disableMiniFiySelector,
|
@@ -97,24 +103,24 @@ let getDevPlugins = (options, publicPath) => {
|
|
97
103
|
}
|
98
104
|
|
99
105
|
if (unusedFiles.enable) {
|
100
|
-
|
106
|
+
pluginsArr.push(new _plugins.UnusedFilesFindPlugin(Object.assign(unusedFiles, {
|
101
107
|
origin: _path.default.join(process.cwd(), folder)
|
102
108
|
})));
|
103
109
|
}
|
104
110
|
|
105
111
|
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.
|
112
|
+
/**
|
113
|
+
* NOTE:
|
114
|
+
* this file name ext .i18n.js added
|
115
|
+
* Because, in service worker they maintain cache as file name based
|
116
|
+
* So, to make differce we added .i18n.js ext.
|
111
117
|
*/
|
112
118
|
|
113
119
|
const i18nFileNameTemplate = 'i18n-chunk/[locale]/[name].i18n.js';
|
114
120
|
const i18nPublicPath = publicPath || '';
|
115
121
|
|
116
122
|
if (i18n.chunkSplitEnable) {
|
117
|
-
|
123
|
+
pluginsArr.push(new _I18nSplitPlugin.default({
|
118
124
|
jsResource: i18n.jsResource,
|
119
125
|
localeVarName: i18n.localeVarName,
|
120
126
|
jsonpFunc: i18n.jsonpFunc,
|
@@ -126,10 +132,10 @@ let getDevPlugins = (options, publicPath) => {
|
|
126
132
|
propertiesFolder: i18n.propertiesFolder
|
127
133
|
}));
|
128
134
|
} else {
|
129
|
-
|
135
|
+
const i18nPath = _path.default.join(process.cwd(), context, 'i18n');
|
130
136
|
|
131
137
|
if (_fs.default.existsSync(i18nPath)) {
|
132
|
-
|
138
|
+
pluginsArr.push(new _copyWebpackPlugin.default([{
|
133
139
|
from: `${i18nPath}/`,
|
134
140
|
to: './i18n/[name].[ext]',
|
135
141
|
toType: 'template'
|
@@ -137,30 +143,26 @@ let getDevPlugins = (options, publicPath) => {
|
|
137
143
|
}
|
138
144
|
}
|
139
145
|
|
140
|
-
tpFolder &&
|
146
|
+
tpFolder && pluginsArr.push(new _copyWebpackPlugin.default([{
|
141
147
|
from: `${_path.default.join(process.cwd(), context, tpFolder)}/`,
|
142
148
|
to: `./${tpFolder}/`,
|
143
149
|
toType: 'dir'
|
144
150
|
}]));
|
145
|
-
|
151
|
+
pluginsArr.push(new _lodashWebpackPlugin.default({
|
146
152
|
collections: true,
|
147
153
|
shorthands: true
|
148
154
|
}));
|
155
|
+
(0, _configHtmlWebpackPlugins.configHtmlWebpackPlugins)(pluginsArr, {
|
156
|
+
enableChunkHash: false,
|
157
|
+
folder,
|
158
|
+
minify: false,
|
159
|
+
inject,
|
160
|
+
crossorigin,
|
161
|
+
hasEFC
|
162
|
+
});
|
149
163
|
|
150
164
|
if (hasEFC) {
|
151
|
-
|
152
|
-
chunksSortMode: 'none',
|
153
|
-
filename: 'index.html',
|
154
|
-
template: _path.default.join(process.cwd(), folder, 'index.html'),
|
155
|
-
excludeChunks: ['efc', 'widget'],
|
156
|
-
templateParameters: _common.templateParameters,
|
157
|
-
scriptLoading: 'defer',
|
158
|
-
inject: inject
|
159
|
-
}));
|
160
|
-
crossorigin && plugins.push(new _htmlWebpackInjectAttributesPlugin.default({
|
161
|
-
crossorigin: 'anonymous'
|
162
|
-
}));
|
163
|
-
plugins.push(new _plugins.EFCPlugin({
|
165
|
+
pluginsArr.push(new _plugins.EFCPlugin({
|
164
166
|
isDevelopment: true,
|
165
167
|
i18nManifestFileName,
|
166
168
|
templateFilePath,
|
@@ -171,21 +173,9 @@ let getDevPlugins = (options, publicPath) => {
|
|
171
173
|
localeAttr: efcLocaleAttr // outputFile: 'zohodesk-efc-sdk-latest.js',
|
172
174
|
|
173
175
|
}));
|
174
|
-
} else {
|
175
|
-
plugins.push(new _htmlWebpackPlugin.default({
|
176
|
-
chunksSortMode: 'none',
|
177
|
-
filename: 'index.html',
|
178
|
-
template: _path.default.join(process.cwd(), folder, 'index.html'),
|
179
|
-
templateParameters: _common.templateParameters,
|
180
|
-
scriptLoading: 'defer',
|
181
|
-
inject: inject
|
182
|
-
}));
|
183
|
-
crossorigin && plugins.push(new _htmlWebpackInjectAttributesPlugin.default({
|
184
|
-
crossorigin: 'anonymous'
|
185
|
-
}));
|
186
176
|
}
|
187
177
|
|
188
|
-
|
178
|
+
pluginsArr.push(new _plugins.I18NInjectIntoIndexPlugin({
|
189
179
|
publicPath: i18nPublicPath,
|
190
180
|
isDevelopment: true,
|
191
181
|
templateLabel: i18n.templateLabel || '{{--user-locale}}',
|
@@ -193,16 +183,28 @@ let getDevPlugins = (options, publicPath) => {
|
|
193
183
|
i18nManifestFileName,
|
194
184
|
mainChunkName: 'main'
|
195
185
|
}));
|
196
|
-
instrumentScript &&
|
197
|
-
hasShadowDOM &&
|
186
|
+
instrumentScript && pluginsArr.push(new _plugins.ScriptInstrumentPlugin());
|
187
|
+
hasShadowDOM && pluginsArr.push(new _plugins.ShadowDOMSupportPlugin());
|
198
188
|
|
199
189
|
if (devCssFileBountry) {
|
200
|
-
|
190
|
+
pluginsArr.push(new _RequireVariablePublicPlugin.default({
|
201
191
|
requireFuncName: 'require'
|
202
192
|
}));
|
203
193
|
}
|
204
194
|
|
205
|
-
|
195
|
+
if (pluginObject.cssVariableReplacement) {
|
196
|
+
pluginsArr.push(new _VariableConversionCollector.default({
|
197
|
+
cssVariableReplacementConfig
|
198
|
+
}));
|
199
|
+
}
|
200
|
+
|
201
|
+
if (pluginObject.selectorWeight) {
|
202
|
+
pluginsArr.push(new _SelectorPlugin.default({
|
203
|
+
selectorWeightConfig
|
204
|
+
}));
|
205
|
+
}
|
206
|
+
|
207
|
+
return pluginsArr.filter(Boolean);
|
206
208
|
};
|
207
209
|
|
208
210
|
var _default = getDevPlugins;
|
@@ -21,24 +21,26 @@ var _miniCssExtractPlugin = _interopRequireDefault(require("mini-css-extract-plu
|
|
21
21
|
|
22
22
|
var _I18nSplitPlugin = _interopRequireDefault(require("../plugins/I18nSplitPlugin"));
|
23
23
|
|
24
|
-
var
|
24
|
+
var _copyWebpackPlugin = _interopRequireDefault(require("copy-webpack-plugin"));
|
25
25
|
|
26
|
-
var
|
26
|
+
var _VariableConversionCollector = _interopRequireDefault(require("../plugins/VariableConversionCollector"));
|
27
27
|
|
28
|
-
var
|
28
|
+
var _SelectorPlugin = _interopRequireDefault(require("../plugins/SelectorPlugin"));
|
29
29
|
|
30
30
|
var _plugins = require("../plugins");
|
31
31
|
|
32
|
-
var _common = require("../common");
|
33
|
-
|
34
32
|
var _RtlCssPlugin = require("../plugins/RtlSplitPlugin/RtlCssPlugin");
|
35
33
|
|
34
|
+
var _configHtmlWebpackPlugins = require("./configHtmlWebpackPlugins");
|
35
|
+
|
36
36
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
37
37
|
|
38
38
|
// eslint-disable-next-line no-unused-vars
|
39
|
-
|
39
|
+
const getProdPlugins = (options, publicPath = '') => {
|
40
40
|
let {
|
41
|
-
enableChunkHash
|
41
|
+
enableChunkHash
|
42
|
+
} = options.app;
|
43
|
+
const {
|
42
44
|
manifestFileName,
|
43
45
|
bundleAnalyze,
|
44
46
|
optimize,
|
@@ -54,15 +56,21 @@ let getProdPlugins = (options, publicPath = '') => {
|
|
54
56
|
mode
|
55
57
|
},
|
56
58
|
hasShadowDOM,
|
59
|
+
cssVariableReplacementConfig,
|
60
|
+
plugins: pluginObject,
|
61
|
+
// exclude,
|
62
|
+
selectorWeightConfig,
|
57
63
|
resourceHints,
|
58
64
|
serviceWorker,
|
59
|
-
htmlTemplate
|
60
|
-
inject
|
61
|
-
},
|
65
|
+
htmlTemplate,
|
62
66
|
tpHashMapping,
|
63
67
|
cdnMapping,
|
64
68
|
crossorigin
|
65
69
|
} = options.app;
|
70
|
+
const {
|
71
|
+
inject,
|
72
|
+
minify: minifyHtmlOptions
|
73
|
+
} = htmlTemplate;
|
66
74
|
const {
|
67
75
|
i18n
|
68
76
|
} = options;
|
@@ -79,9 +87,9 @@ let getProdPlugins = (options, publicPath = '') => {
|
|
79
87
|
const hashTempalate = enableChunkHash ? '.[chunkhash:20]_' : '';
|
80
88
|
const cssLTRFileNameTempalte = `css/[name]${hashTempalate}${enableRTLSplit ? '.ltr' : ''}.css`;
|
81
89
|
const cssRTLFileNameTempalte = `css/[name]${hashTempalate}.rtl.css`;
|
82
|
-
|
90
|
+
const isDevelopment = mode === 'prod' || mode === 'dev' || mode === 'dev-no-warn';
|
83
91
|
enableChunkHash = !isDevelopment && enableChunkHash;
|
84
|
-
|
92
|
+
const pluginsArr = [new _caseSensitivePathsWebpackPlugin.default(), new _webpack.default.IgnorePlugin(/^\.\/locale$/, /moment$/), new _webpack.default.DefinePlugin({
|
85
93
|
__TEST__: false,
|
86
94
|
__DEVELOPMENT__: false,
|
87
95
|
__LOCAL_PRODUCTION__: isDevelopment,
|
@@ -97,7 +105,7 @@ let getProdPlugins = (options, publicPath = '') => {
|
|
97
105
|
}), new _plugins.ResourceHintsPlugin(), new _plugins.UglifyCSSPlugin()];
|
98
106
|
|
99
107
|
if (enableRTLSplit) {
|
100
|
-
|
108
|
+
pluginsArr.push(new _RtlCssPlugin.RtlCssPlugin({
|
101
109
|
templateLabel: options.css.templateLabel,
|
102
110
|
disableMiniFiySelector: options.css.disableMiniFiySelector,
|
103
111
|
dirVarName: options.css.dirVarName,
|
@@ -108,11 +116,11 @@ let getProdPlugins = (options, publicPath = '') => {
|
|
108
116
|
}
|
109
117
|
|
110
118
|
const i18nManifestFileName = 'i18n-manifest.json';
|
111
|
-
/**
|
112
|
-
* NOTE:
|
113
|
-
* this file name ext .i18n.js added
|
114
|
-
* Because, in service worker they maintain cache as file name based
|
115
|
-
* So, to make differce we added .i18n.js ext.
|
119
|
+
/**
|
120
|
+
* NOTE:
|
121
|
+
* this file name ext .i18n.js added
|
122
|
+
* Because, in service worker they maintain cache as file name based
|
123
|
+
* So, to make differce we added .i18n.js ext.
|
116
124
|
*/
|
117
125
|
|
118
126
|
const i18nFileNameTemplate = 'i18n-chunk/[locale]/[name].[chunkhash].i18n.js';
|
@@ -120,7 +128,7 @@ let getProdPlugins = (options, publicPath = '') => {
|
|
120
128
|
// const i18nFileNameTemplate = 'i18n-chunk/[locale]/[name]_.js';
|
121
129
|
|
122
130
|
if (i18n.chunkSplitEnable) {
|
123
|
-
|
131
|
+
pluginsArr.push(new _I18nSplitPlugin.default({
|
124
132
|
jsResource: i18n.jsResource,
|
125
133
|
localeVarName: i18n.localeVarName,
|
126
134
|
jsonpFunc: i18n.jsonpFunc,
|
@@ -132,10 +140,10 @@ let getProdPlugins = (options, publicPath = '') => {
|
|
132
140
|
propertiesFolder: i18n.propertiesFolder
|
133
141
|
}));
|
134
142
|
} else {
|
135
|
-
|
143
|
+
const i18nPath = _path.default.join(process.cwd(), context, 'i18n');
|
136
144
|
|
137
145
|
if (_fs.default.existsSync(i18nPath)) {
|
138
|
-
|
146
|
+
pluginsArr.push(new _copyWebpackPlugin.default([{
|
139
147
|
from: `${i18nPath}/`,
|
140
148
|
to: enableChunkHash ? './i18n/[name].[hash:20]_.[ext]' : './i18n/[name]_.[ext]',
|
141
149
|
toType: 'template'
|
@@ -143,27 +151,22 @@ let getProdPlugins = (options, publicPath = '') => {
|
|
143
151
|
}
|
144
152
|
}
|
145
153
|
|
146
|
-
tpFolder &&
|
154
|
+
tpFolder && pluginsArr.push(new _copyWebpackPlugin.default([{
|
147
155
|
from: `${_path.default.join(process.cwd(), context, tpFolder)}/`,
|
148
156
|
to: `./${tpFolder}/`,
|
149
157
|
toType: 'dir'
|
150
158
|
}]));
|
159
|
+
(0, _configHtmlWebpackPlugins.configHtmlWebpackPlugins)(pluginsArr, {
|
160
|
+
enableChunkHash,
|
161
|
+
folder,
|
162
|
+
inject,
|
163
|
+
minify: minifyHtmlOptions,
|
164
|
+
crossorigin,
|
165
|
+
hasEFC
|
166
|
+
});
|
151
167
|
|
152
168
|
if (hasEFC) {
|
153
|
-
|
154
|
-
chunksSortMode: 'none',
|
155
|
-
filename: enableChunkHash ? 'index.[templatehash:20].html' : 'index.html',
|
156
|
-
template: _path.default.join(process.cwd(), folder, 'index.html'),
|
157
|
-
excludeChunks: ['efc', 'widget'],
|
158
|
-
minify: false,
|
159
|
-
templateParameters: _common.templateParameters,
|
160
|
-
scriptLoading: 'defer',
|
161
|
-
inject: inject
|
162
|
-
}));
|
163
|
-
crossorigin && plugins.push(new _htmlWebpackInjectAttributesPlugin.default({
|
164
|
-
crossorigin: 'anonymous'
|
165
|
-
}));
|
166
|
-
plugins.push(new _plugins.EFCPlugin({
|
169
|
+
pluginsArr.push(new _plugins.EFCPlugin({
|
167
170
|
isDevelopment,
|
168
171
|
serverUrl: publicPath,
|
169
172
|
i18nFileNameTemplate,
|
@@ -175,22 +178,9 @@ let getProdPlugins = (options, publicPath = '') => {
|
|
175
178
|
localeAttr: efcLocaleAttr,
|
176
179
|
cdnVariableName: cdnMapping.isCdnEnabled ? cdnMapping.variableName : null
|
177
180
|
}));
|
178
|
-
} else {
|
179
|
-
plugins.push(new _htmlWebpackPlugin.default({
|
180
|
-
chunksSortMode: 'none',
|
181
|
-
filename: enableChunkHash ? 'index.[templatehash:20].html' : 'index.html',
|
182
|
-
template: _path.default.join(process.cwd(), folder, 'index.html'),
|
183
|
-
minify: false,
|
184
|
-
templateParameters: _common.templateParameters,
|
185
|
-
scriptLoading: 'defer',
|
186
|
-
inject: inject
|
187
|
-
}));
|
188
|
-
crossorigin && plugins.push(new _htmlWebpackInjectAttributesPlugin.default({
|
189
|
-
crossorigin: 'anonymous'
|
190
|
-
}));
|
191
181
|
}
|
192
182
|
|
193
|
-
|
183
|
+
pluginsArr.push(new _plugins.I18NInjectIntoIndexPlugin({
|
194
184
|
// Because we will handle cdn url in CdnChangePlugin
|
195
185
|
publicPath: cdnMapping.isCdnEnabled ? '' : i18nPublicPath,
|
196
186
|
isDevelopment,
|
@@ -201,10 +191,10 @@ let getProdPlugins = (options, publicPath = '') => {
|
|
201
191
|
}));
|
202
192
|
|
203
193
|
if (publicPaths && !isDevelopment && !cdnMapping.isCdnEnabled) {
|
204
|
-
|
194
|
+
const {
|
205
195
|
callback
|
206
196
|
} = publicPaths;
|
207
|
-
|
197
|
+
pluginsArr.push(callback ? new _plugins.PublicPathCallbackPlugin({
|
208
198
|
callback
|
209
199
|
}) : new _plugins.PublicPathChangePlugin({
|
210
200
|
publicPaths,
|
@@ -213,24 +203,24 @@ let getProdPlugins = (options, publicPath = '') => {
|
|
213
203
|
}
|
214
204
|
|
215
205
|
if (cdnMapping.isCdnEnabled) {
|
216
|
-
|
206
|
+
pluginsArr.push(new _plugins.CdnChangePlugin(cdnMapping));
|
217
207
|
}
|
218
208
|
|
219
|
-
|
209
|
+
pluginsArr.push(new _lodashWebpackPlugin.default({
|
220
210
|
collections: true,
|
221
211
|
shorthands: true
|
222
212
|
}));
|
223
|
-
hasShadowDOM &&
|
213
|
+
hasShadowDOM && pluginsArr.push(new _plugins.ShadowDOMSupportPlugin());
|
224
214
|
|
225
215
|
if (!isDevelopment) {
|
226
|
-
enableSMap && enableSMapHook &&
|
227
|
-
optimize &&
|
228
|
-
|
216
|
+
enableSMap && enableSMapHook && pluginsArr.push(new _plugins.SourceMapHookPlugin());
|
217
|
+
optimize && pluginsArr.push(new _plugins.OptimizeJSPlugin());
|
218
|
+
pluginsArr.push(new _plugins.ManifestPlugin({
|
229
219
|
fileName: manifestFileName
|
230
220
|
}));
|
231
221
|
|
232
222
|
if (bundleAnalyze) {
|
233
|
-
|
223
|
+
pluginsArr.push(new _webpackBundleAnalyzer.BundleAnalyzerPlugin({
|
234
224
|
analyzerMode: 'static',
|
235
225
|
generateStatsFile: true,
|
236
226
|
openAnalyzer: false,
|
@@ -247,7 +237,7 @@ let getProdPlugins = (options, publicPath = '') => {
|
|
247
237
|
}
|
248
238
|
|
249
239
|
if (tpHashMapping && tpHashMapping.length > 0) {
|
250
|
-
|
240
|
+
pluginsArr.push(new _plugins.TPHashMappingPlugin({
|
251
241
|
fileMappings: tpHashMapping,
|
252
242
|
tpFolder: `${_path.default.join(process.cwd(), context, tpFolder)}/`
|
253
243
|
}));
|
@@ -255,7 +245,7 @@ let getProdPlugins = (options, publicPath = '') => {
|
|
255
245
|
}
|
256
246
|
|
257
247
|
if (!isDevelopment && serviceWorker.enableSw) {
|
258
|
-
|
248
|
+
const {
|
259
249
|
filePath,
|
260
250
|
fileName = 'sw.js',
|
261
251
|
exitPath = '/',
|
@@ -266,7 +256,7 @@ let getProdPlugins = (options, publicPath = '') => {
|
|
266
256
|
throw new Error('File Path required for service worker plugin');
|
267
257
|
}
|
268
258
|
|
269
|
-
|
259
|
+
pluginsArr.push(new _plugins.ServiceWorkerPlugin({
|
270
260
|
filePath: _path.default.join(process.cwd(), filePath),
|
271
261
|
i18nFileNameTemplate,
|
272
262
|
fileName: fileName,
|
@@ -276,7 +266,20 @@ let getProdPlugins = (options, publicPath = '') => {
|
|
276
266
|
}));
|
277
267
|
}
|
278
268
|
|
279
|
-
|
269
|
+
if (pluginObject.cssVariableReplacement) {
|
270
|
+
pluginsArr.push(new _VariableConversionCollector.default({
|
271
|
+
cssVariableReplacementConfig
|
272
|
+
}));
|
273
|
+
}
|
274
|
+
|
275
|
+
if (pluginObject.selectorWeight) {
|
276
|
+
pluginsArr.push(new _SelectorPlugin.default({
|
277
|
+
selectorWeightConfig
|
278
|
+
}));
|
279
|
+
} // plugins.push(new VariableConversionCollector({}));
|
280
|
+
|
281
|
+
|
282
|
+
return pluginsArr;
|
280
283
|
};
|
281
284
|
|
282
285
|
var _default = getProdPlugins;
|
package/lib/plugins/EFCPlugin.md
CHANGED
@@ -1,6 +1,6 @@
|
|
1
|
-
# EFC Plugin
|
2
|
-
|
3
|
-
In EFC plugin we are create sdk file for efc related purpose
|
4
|
-
|
5
|
-
|
6
|
-
# document will be soon
|
1
|
+
# EFC Plugin
|
2
|
+
|
3
|
+
In EFC plugin we are create sdk file for efc related purpose
|
4
|
+
|
5
|
+
|
6
|
+
# document will be soon
|
@@ -116,10 +116,10 @@ class I18NInjectIntoIndexPlugin {
|
|
116
116
|
i18nObj = i18nFiles.reduce((res, next) => {
|
117
117
|
let fileName = next.replace(`i18n${_path.default.sep}`, '');
|
118
118
|
let splittedFileName = fileName.split('.');
|
119
|
-
/* if (this.isDevelopment) {
|
120
|
-
res[splittedFileName[0]] = `${this.publicPath}/i18n/${fileName}`;
|
121
|
-
} else {
|
122
|
-
res[splittedFileName[0]] = fileName;
|
119
|
+
/* if (this.isDevelopment) {
|
120
|
+
res[splittedFileName[0]] = `${this.publicPath}/i18n/${fileName}`;
|
121
|
+
} else {
|
122
|
+
res[splittedFileName[0]] = fileName;
|
123
123
|
} */
|
124
124
|
|
125
125
|
res[splittedFileName[0]] = `${this.publicPath}/i18n/${fileName}`;
|
@@ -13,23 +13,23 @@ var _hashUtils = require("./utils/hashUtils");
|
|
13
13
|
|
14
14
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
15
15
|
|
16
|
-
/**
|
17
|
-
* this plugin for the download i18n files
|
18
|
-
* So, if need to downoad i18n in browser this plugin handle that
|
19
|
-
*
|
20
|
-
*
|
21
|
-
* this plugin works
|
22
|
-
* how it works?
|
23
|
-
* this plugin hook the requireEnsure method and we write logic for current compiled file download logic
|
24
|
-
*
|
25
|
-
* hinds:-
|
26
|
-
* requireEnsure method was loader for all js chunk's ,
|
27
|
-
* which means if we use dynamic import then this function will create script tag for that dynamic resource
|
28
|
-
* so every dynamic js chunk will load by this function,
|
29
|
-
* So we update this function with when dynamic jschunk call the nour code also execute
|
30
|
-
*
|
31
|
-
* some thing missing in this definetion
|
32
|
-
*
|
16
|
+
/**
|
17
|
+
* this plugin for the download i18n files
|
18
|
+
* So, if need to downoad i18n in browser this plugin handle that
|
19
|
+
*
|
20
|
+
*
|
21
|
+
* this plugin works
|
22
|
+
* how it works?
|
23
|
+
* this plugin hook the requireEnsure method and we write logic for current compiled file download logic
|
24
|
+
*
|
25
|
+
* hinds:-
|
26
|
+
* requireEnsure method was loader for all js chunk's ,
|
27
|
+
* which means if we use dynamic import then this function will create script tag for that dynamic resource
|
28
|
+
* so every dynamic js chunk will load by this function,
|
29
|
+
* So we update this function with when dynamic jschunk call the nour code also execute
|
30
|
+
*
|
31
|
+
* some thing missing in this definetion
|
32
|
+
*
|
33
33
|
*/
|
34
34
|
// import { REGEXP_HASH, REGEXP_CHUNKHASH } from './utils/hashUtils';
|
35
35
|
const pluginName = 'DownloadLogicOfI18n'; // const pluginName = 'i18n-plugin';
|
@@ -126,20 +126,20 @@ class I18nDownlodLogic {
|
|
126
126
|
return _webpack.Template.asString([source, '', '// object to store loaded I18N chunks', 'var installedI18nChunks = {', _webpack.Template.indent(mainChunk.ids.map(id => `${JSON.stringify(id)}: 0`).join(',\n')), '};']);
|
127
127
|
});
|
128
128
|
mainTemplate.hooks.requireEnsure.tap(pluginName, (source, mainChunk, hash) => {
|
129
|
-
/**
|
130
|
-
* for Information this is tapped in mainTemplate ,
|
131
|
-
* So this hooks argument chunk is main chunk means entry chunk mostly.
|
132
|
-
* if any chunk has i18n then we must write our download i18n logic,
|
129
|
+
/**
|
130
|
+
* for Information this is tapped in mainTemplate ,
|
131
|
+
* So this hooks argument chunk is main chunk means entry chunk mostly.
|
132
|
+
* if any chunk has i18n then we must write our download i18n logic,
|
133
133
|
*/
|
134
134
|
const chunkMap = this.getI18nChunkObject(mainChunk);
|
135
135
|
|
136
136
|
if (!Object.keys(chunkMap).length) {
|
137
137
|
return source;
|
138
138
|
}
|
139
|
-
/**
|
140
|
-
* chunkMaps has
|
141
|
-
* @property {Object} hash [it has key as chunk id and value as chunkHash ]
|
142
|
-
* @property {Object} name [it has key as chunk id and value as chunk name ]
|
139
|
+
/**
|
140
|
+
* chunkMaps has
|
141
|
+
* @property {Object} hash [it has key as chunk id and value as chunkHash ]
|
142
|
+
* @property {Object} name [it has key as chunk id and value as chunk name ]
|
143
143
|
*/
|
144
144
|
|
145
145
|
|
@@ -176,22 +176,22 @@ class I18nDownlodLogic {
|
|
176
176
|
},
|
177
177
|
contentHashType: MODULE_TYPE
|
178
178
|
});
|
179
|
-
/** IDEA:
|
180
|
-
* as my suggestion ignore this `jsop` approch,
|
181
|
-
* Because json parse is faster then js parse.
|
182
|
-
* my suggestion is make ajax or fetch request
|
179
|
+
/** IDEA:
|
180
|
+
* as my suggestion ignore this `jsop` approch,
|
181
|
+
* Because json parse is faster then js parse.
|
182
|
+
* my suggestion is make ajax or fetch request
|
183
183
|
*/
|
184
184
|
|
185
185
|
const buf = [];
|
186
|
-
/*
|
187
|
-
if (REGEXP_HASH.test(filenameTemplate)) {
|
188
|
-
buf.push(
|
189
|
-
`var hash = ${mainTemplate.renderCurrentHashCode(hash)};`
|
190
|
-
);
|
191
|
-
}
|
192
|
-
if (REGEXP_CHUNKHASH.test(filenameTemplate)) {
|
193
|
-
buf.push(`var chunkHashes = ${JSON.stringify(chunkMaps.hash)};`);
|
194
|
-
}
|
186
|
+
/*
|
187
|
+
if (REGEXP_HASH.test(filenameTemplate)) {
|
188
|
+
buf.push(
|
189
|
+
`var hash = ${mainTemplate.renderCurrentHashCode(hash)};`
|
190
|
+
);
|
191
|
+
}
|
192
|
+
if (REGEXP_CHUNKHASH.test(filenameTemplate)) {
|
193
|
+
buf.push(`var chunkHashes = ${JSON.stringify(chunkMaps.hash)};`);
|
194
|
+
}
|
195
195
|
*/
|
196
196
|
|
197
197
|
if ((0, _hashUtils.hasContentHash)(filenameTemplate)) {
|