@zohodesk/react-cli 0.0.1-exp.169.2 → 0.0.1-exp.175.0

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.
Files changed (128) hide show
  1. package/.eslintignore +7 -7
  2. package/.eslintrc.js +180 -179
  3. package/.prettierrc +6 -6
  4. package/{CHANGELOG.md → CHANGELOG-fz.md} +0 -0
  5. package/Changelog.md +1019 -0
  6. package/README.md +27 -951
  7. package/bin/cli.js +483 -483
  8. package/docs/CustomChunks.md +26 -26
  9. package/docs/DevStart.md +18 -18
  10. package/docs/HoverActive.md +12 -12
  11. package/docs/InstallNode.md +28 -28
  12. package/docs/TODOS.md +10 -10
  13. package/docs/ValueReplacer.md +60 -60
  14. package/docs/VariableConversion.md +678 -0
  15. package/docs/warnings_while_install.txt +35 -35
  16. package/files/eslintrc.js +62 -62
  17. package/files/prettierrc.js +3 -3
  18. package/lib/configs/jest.config.js +8 -12
  19. package/lib/configs/libAlias.js +10 -3
  20. package/lib/configs/resolvers.js +38 -0
  21. package/lib/configs/webpack.css.umd.config.js +4 -4
  22. package/lib/configs/webpack.dev.config.js +17 -22
  23. package/lib/configs/webpack.docs.config.js +10 -15
  24. package/lib/configs/webpack.impact.config.js +11 -11
  25. package/lib/configs/webpack.prod.config.js +22 -24
  26. package/lib/constants.js +31 -0
  27. package/lib/jest/preProcessors/cssPreprocessor.js +16 -7
  28. package/lib/loaderUtils/configsAssetsLoaders.js +33 -33
  29. package/lib/loaderUtils/getCSSLoaders.js +42 -22
  30. package/lib/loaders/workerLoader.js +9 -9
  31. package/lib/pluginUtils/configHtmlWebpackPlugins.js +59 -0
  32. package/lib/pluginUtils/getDevPlugins.js +19 -39
  33. package/lib/pluginUtils/getProdPlugins.js +29 -47
  34. package/lib/plugins/EFCPlugin.md +6 -6
  35. package/lib/plugins/I18NInjectIntoIndexPlugin.js +4 -4
  36. package/lib/plugins/I18nSplitPlugin/I18nDownlodLogic.js +38 -38
  37. package/lib/plugins/I18nSplitPlugin/I18nFilesEmitter.js +30 -30
  38. package/lib/plugins/I18nSplitPlugin/I18nKeysIdentifer.js +8 -8
  39. package/lib/plugins/I18nSplitPlugin/I18nSplit.md +95 -95
  40. package/lib/plugins/I18nSplitPlugin/README.md +25 -25
  41. package/lib/plugins/I18nSplitPlugin/index.js +57 -57
  42. package/lib/plugins/ResourceHintsPlugin.js +17 -17
  43. package/lib/plugins/RtlSplitPlugin/RtlCssPlugin.js +16 -24
  44. package/lib/plugins/RtlSplitPlugin/RtrSplit.md +30 -30
  45. package/lib/plugins/ServiceWorkerPlugin.js +9 -9
  46. package/lib/plugins/TPHashMappingPlugin.js +4 -4
  47. package/lib/postcss-plugins/RTLSplitPlugin.js +10 -10
  48. package/lib/postcss-plugins/__test__/test1Input.css +38 -38
  49. package/lib/postcss-plugins/__test__/test1Output.css +38 -38
  50. package/lib/postcss-plugins/hoverActivePlugin.js +54 -30
  51. package/lib/postcss-plugins/variableModificationPlugin/ErrorHandler.js +37 -0
  52. package/lib/postcss-plugins/variableModificationPlugin/index.js +248 -0
  53. package/lib/postcss-plugins/variableModifier.js +1 -0
  54. package/lib/schemas/index.js +36 -8
  55. package/lib/servers/docsServerCore.js +13 -12
  56. package/lib/servers/getCliPath.js +1 -1
  57. package/lib/servers/httpsOptions.js +40 -9
  58. package/lib/servers/nowatchserver.js +12 -11
  59. package/lib/servers/server.js +14 -13
  60. package/lib/sh/pre-commit.sh +34 -34
  61. package/lib/sh/reportPublish.sh +45 -45
  62. package/lib/utils/buildstats.html +148 -148
  63. package/lib/utils/getOptions.js +42 -14
  64. package/lib/utils/resultSchema.json +73 -73
  65. package/npm8.md +9 -9
  66. package/package.json +119 -148
  67. package/postpublish.js +8 -6
  68. package/templates/app/.eslintrc.js +140 -140
  69. package/templates/app/README.md +12 -12
  70. package/templates/app/app/index.html +24 -24
  71. package/templates/app/app/properties/ApplicationResources_en_US.properties +1 -1
  72. package/templates/app/app/properties/i18nkeys.json +3 -3
  73. package/templates/app/docs/all.html +69 -69
  74. package/templates/app/mockapi/index.js +18 -18
  75. package/templates/app/package.json +37 -37
  76. package/templates/app/src/actions/SampleActions/index.js +37 -37
  77. package/templates/app/src/actions/index.js +65 -65
  78. package/templates/app/src/appUrls.js +19 -19
  79. package/templates/app/src/components/Alert/Alert.js +134 -134
  80. package/templates/app/src/components/Alert/Alert.module.css +79 -79
  81. package/templates/app/src/components/FreezeLayer/FreezeLayer.css +37 -37
  82. package/templates/app/src/components/FreezeLayer/FreezeLayer.js +84 -84
  83. package/templates/app/src/components/Sample/Sample.module.css +11 -11
  84. package/templates/app/src/components/Sample/SampleList.js +61 -61
  85. package/templates/app/src/components/Slider/Slider.css +41 -41
  86. package/templates/app/src/components/Slider/Slider.js +55 -55
  87. package/templates/app/src/containers/AlertContainer/index.js +15 -15
  88. package/templates/app/src/containers/AppContainer/index.js +96 -96
  89. package/templates/app/src/containers/AppContainer/index.module.css +27 -27
  90. package/templates/app/src/containers/CustomMatch/index.js +65 -65
  91. package/templates/app/src/containers/DevTools/index.js +10 -10
  92. package/templates/app/src/containers/Header/index.js +67 -67
  93. package/templates/app/src/containers/Header/index.module.css +43 -43
  94. package/templates/app/src/containers/Redirect/index.js +63 -63
  95. package/templates/app/src/containers/Redirector/index.js +47 -47
  96. package/templates/app/src/containers/SampleListContainer/ListContainer.js +42 -42
  97. package/templates/app/src/containers/SampleListContainer/ListContainer.module.css +3 -3
  98. package/templates/app/src/historyChange.js +5 -5
  99. package/templates/app/src/index.html +10 -10
  100. package/templates/app/src/index.js +24 -24
  101. package/templates/app/src/middleware/PromiseMiddleware.js +59 -59
  102. package/templates/app/src/reducers/alertData.js +11 -11
  103. package/templates/app/src/reducers/index.js +6 -6
  104. package/templates/app/src/reducers/samples.js +19 -19
  105. package/templates/app/src/store/configureStore.dev.js +51 -51
  106. package/templates/app/src/store/configureStore.js +5 -5
  107. package/templates/app/src/store/configureStore.prod.js +26 -26
  108. package/templates/app/src/util/Common.js +5 -5
  109. package/templates/app/src/util/RequestAPI.js +132 -132
  110. package/templates/docs/all.html +249 -249
  111. package/templates/docs/component.html +178 -178
  112. package/templates/docs/components.html +221 -221
  113. package/templates/docs/css/b.min.css +6 -6
  114. package/templates/docs/css/component.css +42 -42
  115. package/templates/docs/css/componentTest.css +6 -6
  116. package/templates/docs/css/hopscotch.css +585 -585
  117. package/templates/docs/css/style.css +1022 -1022
  118. package/templates/docs/impactReportTemplate.html +154 -154
  119. package/templates/docs/index.html +1501 -1493
  120. package/templates/docs/js/active-line.js +72 -72
  121. package/templates/docs/js/b.min.js +7 -7
  122. package/templates/docs/js/codemirror.js +9680 -9680
  123. package/templates/docs/js/designTokens.js +334 -334
  124. package/templates/docs/js/j.min.js +4 -4
  125. package/templates/docs/js/javascript.js +874 -874
  126. package/templates/docs/js/matchbrackets.js +145 -145
  127. package/cert/Tsicsezwild-22-23.crt +0 -37
  128. package/cert/Tsicsezwild-22-23.key +0 -27
@@ -0,0 +1,31 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.cliRootPath = exports.cliNodemodulesPath = exports.appPath = exports.CONFIG_ROOT = exports.BASE_CONFIG_KEY = void 0;
7
+
8
+ var _path = _interopRequireDefault(require("path"));
9
+
10
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
11
+
12
+ const BASE_CONFIG_KEY = 'react-cli';
13
+ exports.BASE_CONFIG_KEY = BASE_CONFIG_KEY;
14
+
15
+ const cliRootPath = _path.default.resolve(__dirname, '..');
16
+
17
+ exports.cliRootPath = cliRootPath;
18
+ const CONFIG_ROOT = 'react-cli';
19
+ exports.CONFIG_ROOT = CONFIG_ROOT;
20
+
21
+ const cliNodemodulesPath = _path.default.resolve(cliRootPath, 'node_modules'); // export const babelrcPath = join(cliRootPath, '.babelrc');
22
+
23
+
24
+ exports.cliNodemodulesPath = cliNodemodulesPath;
25
+ const appPath = process.cwd(); // export const appInitialHTMLTemplatePath = path.join(
26
+ // process.cwd(),
27
+ // 'src',
28
+ // 'index.html'
29
+ // );
30
+
31
+ exports.appPath = appPath;
@@ -6,23 +6,32 @@ var _postcssHashClassname = _interopRequireDefault(require("postcss-hash-classna
6
6
 
7
7
  var _fs = _interopRequireDefault(require("fs"));
8
8
 
9
+ var _utils = require("../../utils");
10
+
9
11
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
10
12
 
11
13
  let count = 0;
14
+ const options = (0, _utils.getOptions)();
15
+ const {
16
+ classnameFormat
17
+ } = options.test;
12
18
  module.exports = {
13
19
  process: function (src) {
14
20
  count++;
15
- let opts = {
21
+ const opts = {
16
22
  hashType: 'md5',
17
- digestType: 'base32'
23
+ digestType: 'base32',
24
+ maxLength: 6,
25
+ type: '.json',
26
+ classnameFormat: classnameFormat,
27
+ outputName: `jsonFile_test_${count}`
18
28
  };
19
- opts.maxLength = 6;
20
- opts.type = '.json';
21
- opts.outputName = `jsonFile_test_${count}`;
22
- let processor = (0, _postcss.default)([(0, _postcssHashClassname.default)(opts)]);
29
+ const processor = (0, _postcss.default)([(0, _postcssHashClassname.default)(opts)]);
23
30
  processor.process(src).css;
24
31
 
25
- let jsonMap = _fs.default.readFileSync(`jsonFile_test_${count}.json`, 'UTF-8');
32
+ const jsonMap = _fs.default.readFileSync(`jsonFile_test_${count}.json`, 'UTF-8');
33
+
34
+ _fs.default.unlinkSync(`jsonFile_test_${count}.json`);
26
35
 
27
36
  return `module.exports =${jsonMap}`;
28
37
  }
@@ -79,39 +79,39 @@ function createNameTemplate(enableChunkHash) {
79
79
  const ext = `${enableChunkHash ? '.[hash:20]' : ''}.[ext]`;
80
80
  return `[name]${ext}`;
81
81
  }
82
- /*
83
- export function createImageAndFontsAndSVGLoaders(enableChunkHash) {
84
- const nameTemplate = createNameTemplate(enableChunkHash);
85
- return [
86
- configImageLoader(nameTemplate),
87
- configFontLoader(nameTemplate),
88
- configSVGLoader(nameTemplate),
89
- configAudioLoader(nameTemplate)
90
- ];
91
- }
82
+ /*
83
+ export function createImageAndFontsAndSVGLoaders(enableChunkHash) {
84
+ const nameTemplate = createNameTemplate(enableChunkHash);
85
+ return [
86
+ configImageLoader(nameTemplate),
87
+ configFontLoader(nameTemplate),
88
+ configSVGLoader(nameTemplate),
89
+ configAudioLoader(nameTemplate)
90
+ ];
91
+ }
92
92
  */
93
93
 
94
- /*
95
- export function createLoaderOptionObject(
96
- loaderName,
97
- nameTemplate,
98
- fallback,
99
- limit = 1000
100
- ) {
101
- return {
102
- loader: loaderName,
103
- options: {
104
- limit,
105
- name: nameTemplate,
106
- fallback
107
- }
108
- };
109
- }
110
-
111
- function configLoaderObject(filter, loaderAndOptions) {
112
- return {
113
- test: filter,
114
- use: loaderAndOptions
115
- };
116
- }
94
+ /*
95
+ export function createLoaderOptionObject(
96
+ loaderName,
97
+ nameTemplate,
98
+ fallback,
99
+ limit = 1000
100
+ ) {
101
+ return {
102
+ loader: loaderName,
103
+ options: {
104
+ limit,
105
+ name: nameTemplate,
106
+ fallback
107
+ }
108
+ };
109
+ }
110
+
111
+ function configLoaderObject(filter, loaderAndOptions) {
112
+ return {
113
+ test: filter,
114
+ use: loaderAndOptions
115
+ };
116
+ }
117
117
  */
@@ -13,14 +13,27 @@ var _utils = require("../utils");
13
13
 
14
14
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
15
15
 
16
- let options = (0, _utils.getOptions)();
17
- let isWin = process.platform === 'win32';
16
+ const fs = require('fs');
18
17
 
19
- let getCSSLoaders = (plugins, exclude, classNameBlob, cssUniqueness, selectorReplace, cssHashSelectors, classNamePrefix) => {
20
- // console.log('plugins:')
21
- // console.log(plugins)
22
- // console.log('exclude:')
23
- // console.log(exclude)
18
+ const options = (0, _utils.getOptions)();
19
+ const isWin = process.platform === 'win32';
20
+
21
+ function windowsModification(array) {
22
+ return isWin ? array.map(r => r.replace(/\//g, '\\')) : array;
23
+ }
24
+
25
+ function excludeEmptyCheckPlugin({
26
+ enable,
27
+ ignore,
28
+ plugins
29
+ }) {
30
+ return enable ? ignore.length === 0 ? plugins : [require('../postcss-plugins/ExcludePlugin')({
31
+ ignore,
32
+ plugins
33
+ })] : [];
34
+ }
35
+
36
+ const getCSSLoaders = (plugins, exclude, mediaQueryHoverActiveString, cssVariableReplacementConfig, classNameBlob, cssUniqueness, selectorReplace, cssHashSelectors, classNamePrefix) => {
24
37
  const {
25
38
  devCssFileBountry
26
39
  } = options.app;
@@ -30,15 +43,11 @@ let getCSSLoaders = (plugins, exclude, classNameBlob, cssUniqueness, selectorRep
30
43
  const {
31
44
  cssSelectorZipPath
32
45
  } = options.impactService;
33
-
34
- function windowsModification(array) {
35
- return isWin ? array.map(r => r.replace(/\//g, '\\')) : array;
36
- }
37
-
38
- let rtlExcludeLocal = windowsModification(exclude.rtl);
39
- let hoverActiveExcludeLocal = windowsModification(exclude.hoverActive);
40
- let combinerMediaQueryExcludeLocal = windowsModification(exclude.combinerMediaQuery);
41
- let cssLoaderOptions = {
46
+ const rtlExcludeLocal = windowsModification(exclude.rtl);
47
+ const hoverActiveExcludeLocal = windowsModification(exclude.hoverActive);
48
+ const combinerMediaQueryExcludeLocal = windowsModification(exclude.combinerMediaQuery);
49
+ const cssVariableReplacementExcludeLocal = windowsModification(exclude.cssVariableReplacement);
50
+ const cssLoaderOptions = {
42
51
  // importLoaders: hasRTL||hoverActive ? 1 : 0,
43
52
  importLoaders: 1,
44
53
  modules: {},
@@ -51,7 +60,13 @@ let getCSSLoaders = (plugins, exclude, classNameBlob, cssUniqueness, selectorRep
51
60
  cssLoaderOptions.modules.getLocalIdent = (0, _cssClassNameGenerate.default)(cssUniqueness, cssHashSelectors, classNamePrefix);
52
61
  }
53
62
 
54
- const postcssPlugins = [valueReplacer && require('../postcss-plugins/ValueReplacer')(valueReplacer), selectorReplace && require('postcss-selector-replace')(selectorReplace), plugins.hasRTL && require('../postcss-plugins/ExcludePlugin')({
63
+ const postcssPlugins = [valueReplacer && require('../postcss-plugins/ValueReplacer')(valueReplacer), selectorReplace && require('postcss-selector-replace')(selectorReplace), // ...excludeEmptyCheckPlugin({
64
+ // enable: true,
65
+ // ignore: [],
66
+ // plugins: [require('../postcss-plugins/variablePropertiesCollector').default()]
67
+ // }),
68
+ ...excludeEmptyCheckPlugin({
69
+ enable: plugins.hasRTL,
55
70
  ignore: rtlExcludeLocal,
56
71
  plugins: [require('@zohodesk/postcss-rtl')({
57
72
  addPrefixToSelector: function addPrefixToSelector(selector, prefix) {
@@ -62,14 +77,19 @@ let getCSSLoaders = (plugins, exclude, classNameBlob, cssUniqueness, selectorRep
62
77
  return `${prefix} ${selector}`; // Make selectors like [dir=rtl] > .selector
63
78
  }
64
79
  })]
65
- }), plugins.combinerMediaQuery && require('../postcss-plugins/ExcludePlugin')({
80
+ }), ...excludeEmptyCheckPlugin({
81
+ enable: plugins.combinerMediaQuery,
66
82
  ignore: combinerMediaQueryExcludeLocal,
67
83
  plugins: [require('postcss-combine-media-query')]
68
- }), plugins.hoverActive && require('../postcss-plugins/ExcludePlugin')({
84
+ }), ...excludeEmptyCheckPlugin({
85
+ enable: plugins.hoverActive,
69
86
  ignore: hoverActiveExcludeLocal,
70
- plugins: [require('../postcss-plugins/hoverActivePlugin')]
71
- }) // require('../postcss-plugins/variableModifier')()
72
- ].filter(Boolean);
87
+ plugins: [require('../postcss-plugins/hoverActivePlugin')(mediaQueryHoverActiveString)]
88
+ }), ...excludeEmptyCheckPlugin({
89
+ enable: plugins.cssVariableReplacement,
90
+ ignore: cssVariableReplacementExcludeLocal,
91
+ plugins: [fs.existsSync(cssVariableReplacementConfig) && require('../postcss-plugins/variableModificationPlugin/index')(cssVariableReplacementConfig)]
92
+ })].filter(Boolean);
73
93
  return [cssSelectorZipPath && {
74
94
  loader: require.resolve('../loaders/selectorMappingLoader')
75
95
  }, {
@@ -16,7 +16,7 @@ var _SingleEntryPlugin = _interopRequireDefault(require("webpack/lib/SingleEntry
16
16
 
17
17
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
18
18
 
19
- /* import WebWorkerTemplatePlugin from 'webpack/lib/webworker/WebWorkerTemplatePlugin';
19
+ /* import WebWorkerTemplatePlugin from 'webpack/lib/webworker/WebWorkerTemplatePlugin';
20
20
  import ExternalsPlugin from 'webpack/lib/ExternalsPlugin'; */
21
21
  const schema = {
22
22
  'type': 'object',
@@ -80,14 +80,14 @@ function pitch(request) {
80
80
  globalObject: 'self'
81
81
  };
82
82
  workerContext.compiler = this._compilation.createChildCompiler(`worker-loader ${request}`, workerContext.options);
83
- /*
84
- new WebWorkerTemplatePlugin().apply(workerContext.compiler);
85
-
86
- if (compilerOptions.externals) {
87
- new ExternalsPlugin(
88
- getExternalsType(compilerOptions),
89
- compilerOptions.externals
90
- ).apply(workerContext.compiler);
83
+ /*
84
+ new WebWorkerTemplatePlugin().apply(workerContext.compiler);
85
+
86
+ if (compilerOptions.externals) {
87
+ new ExternalsPlugin(
88
+ getExternalsType(compilerOptions),
89
+ compilerOptions.externals
90
+ ).apply(workerContext.compiler);
91
91
  } */
92
92
 
93
93
  new _SingleEntryPlugin.default(this.context, `!!${request}`, _path.default.parse(this.resourcePath).name).apply(workerContext.compiler);
@@ -0,0 +1,59 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.configHtmlWebpackPlugins = configHtmlWebpackPlugins;
7
+
8
+ var _path = _interopRequireDefault(require("path"));
9
+
10
+ var _htmlWebpackPlugin = _interopRequireDefault(require("html-webpack-plugin"));
11
+
12
+ var _htmlWebpackInjectAttributesPlugin = _interopRequireDefault(require("html-webpack-inject-attributes-plugin"));
13
+
14
+ var _common = require("../common");
15
+
16
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
17
+
18
+ const defaultHTMLMiniFyOption = {
19
+ collapseWhitespace: true,
20
+ minifyCSS: true,
21
+ minifyJS: true,
22
+ keepClosingSlash: true,
23
+ removeComments: false,
24
+ removeRedundantAttributes: true,
25
+ removeScriptTypeAttributes: true,
26
+ removeStyleLinkTypeAttributes: true,
27
+ useShortDoctype: true
28
+ };
29
+
30
+ function configHtmlWebpackPlugins(plugins, {
31
+ enableChunkHash = false,
32
+ folder,
33
+ inject,
34
+ crossorigin,
35
+ hasEFC,
36
+ minify: minifyHtmlOptions = false
37
+ }) {
38
+ const optionsHtmlWebpack = {
39
+ chunksSortMode: 'none',
40
+ filename: enableChunkHash ? 'index.[templatehash:20].html' : 'index.html',
41
+ template: _path.default.join(process.cwd(), folder, 'index.html'),
42
+ minify: minifyHtmlOptions === true ? defaultHTMLMiniFyOption : minifyHtmlOptions === null ? false : minifyHtmlOptions,
43
+ // : typeof minifyHtmlOptions === 'object'
44
+ // ? minifyHtmlOptions
45
+ // : minifyHtmlOptions,,
46
+ templateParameters: _common.templateParameters,
47
+ scriptLoading: 'defer',
48
+ inject: inject
49
+ };
50
+
51
+ if (hasEFC) {
52
+ optionsHtmlWebpack.excludeChunks = ['efc', 'widget'];
53
+ }
54
+
55
+ plugins.push(new _htmlWebpackPlugin.default(optionsHtmlWebpack));
56
+ crossorigin && plugins.push(new _htmlWebpackInjectAttributesPlugin.default({
57
+ crossorigin: 'anonymous'
58
+ }));
59
+ }
@@ -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,14 @@ 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 _configHtmlWebpackPlugins = require("./configHtmlWebpackPlugins");
31
+
36
32
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
37
33
 
38
- let getDevPlugins = (options, publicPath) => {
39
- let {
34
+ const getDevPlugins = (options, publicPath) => {
35
+ const {
40
36
  app: {
41
37
  tpFolder,
42
38
  folder,
@@ -68,7 +64,7 @@ let getDevPlugins = (options, publicPath) => {
68
64
  const hasEFC = newOptionForEnableEFC || prevOptionForEnableEFC;
69
65
  const cssLTRFileNameTempalte = enableRTLSplit ? 'css/[name].ltr.css' : 'css/[name].css';
70
66
  const cssRTLFileNameTempalte = 'css/[name].rtl.css';
71
- let plugins = [new _plugins.CleanUpStatsPlugin(), new _caseSensitivePathsWebpackPlugin.default(), new _webpack.default.IgnorePlugin(/^\.\/domain$/, /moment$/), new _webpack.default.DefinePlugin({
67
+ const plugins = [new _plugins.CleanUpStatsPlugin(), new _caseSensitivePathsWebpackPlugin.default(), new _webpack.default.IgnorePlugin(/^\.\/domain$/, /moment$/), new _webpack.default.DefinePlugin({
72
68
  __CLIENT__: true,
73
69
  __TEST__: false,
74
70
  __SERVER__: false,
@@ -103,11 +99,11 @@ let getDevPlugins = (options, publicPath) => {
103
99
  }
104
100
 
105
101
  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.
102
+ /**
103
+ * NOTE:
104
+ * this file name ext .i18n.js added
105
+ * Because, in service worker they maintain cache as file name based
106
+ * So, to make differce we added .i18n.js ext.
111
107
  */
112
108
 
113
109
  const i18nFileNameTemplate = 'i18n-chunk/[locale]/[name].i18n.js';
@@ -126,7 +122,7 @@ let getDevPlugins = (options, publicPath) => {
126
122
  propertiesFolder: i18n.propertiesFolder
127
123
  }));
128
124
  } else {
129
- let i18nPath = _path.default.join(process.cwd(), context, 'i18n');
125
+ const i18nPath = _path.default.join(process.cwd(), context, 'i18n');
130
126
 
131
127
  if (_fs.default.existsSync(i18nPath)) {
132
128
  plugins.push(new _copyWebpackPlugin.default([{
@@ -146,20 +142,16 @@ let getDevPlugins = (options, publicPath) => {
146
142
  collections: true,
147
143
  shorthands: true
148
144
  }));
145
+ (0, _configHtmlWebpackPlugins.configHtmlWebpackPlugins)(plugins, {
146
+ enableChunkHash: false,
147
+ folder,
148
+ minify: false,
149
+ inject,
150
+ crossorigin,
151
+ hasEFC
152
+ });
149
153
 
150
154
  if (hasEFC) {
151
- plugins.push(new _htmlWebpackPlugin.default({
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
155
  plugins.push(new _plugins.EFCPlugin({
164
156
  isDevelopment: true,
165
157
  i18nManifestFileName,
@@ -171,18 +163,6 @@ let getDevPlugins = (options, publicPath) => {
171
163
  localeAttr: efcLocaleAttr // outputFile: 'zohodesk-efc-sdk-latest.js',
172
164
 
173
165
  }));
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
166
  }
187
167
 
188
168
  plugins.push(new _plugins.I18NInjectIntoIndexPlugin({
@@ -21,24 +21,22 @@ 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
- var _htmlWebpackInjectAttributesPlugin = _interopRequireDefault(require("html-webpack-inject-attributes-plugin"));
27
-
28
24
  var _copyWebpackPlugin = _interopRequireDefault(require("copy-webpack-plugin"));
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 _configHtmlWebpackPlugins = require("./configHtmlWebpackPlugins");
31
+
36
32
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
37
33
 
38
34
  // eslint-disable-next-line no-unused-vars
39
- let getProdPlugins = (options, publicPath = '') => {
35
+ const getProdPlugins = (options, publicPath = '') => {
40
36
  let {
41
- enableChunkHash,
37
+ enableChunkHash
38
+ } = options.app;
39
+ const {
42
40
  manifestFileName,
43
41
  bundleAnalyze,
44
42
  optimize,
@@ -56,13 +54,15 @@ let getProdPlugins = (options, publicPath = '') => {
56
54
  hasShadowDOM,
57
55
  resourceHints,
58
56
  serviceWorker,
59
- htmlTemplate: {
60
- inject
61
- },
57
+ htmlTemplate,
62
58
  tpHashMapping,
63
59
  cdnMapping,
64
60
  crossorigin
65
61
  } = options.app;
62
+ const {
63
+ inject,
64
+ minify: minifyHtmlOptions
65
+ } = htmlTemplate;
66
66
  const {
67
67
  i18n
68
68
  } = options;
@@ -79,9 +79,9 @@ let getProdPlugins = (options, publicPath = '') => {
79
79
  const hashTempalate = enableChunkHash ? '.[chunkhash:20]_' : '';
80
80
  const cssLTRFileNameTempalte = `css/[name]${hashTempalate}${enableRTLSplit ? '.ltr' : ''}.css`;
81
81
  const cssRTLFileNameTempalte = `css/[name]${hashTempalate}.rtl.css`;
82
- let isDevelopment = mode === 'prod' || mode === 'dev' || mode === 'dev-no-warn';
82
+ const isDevelopment = mode === 'prod' || mode === 'dev' || mode === 'dev-no-warn';
83
83
  enableChunkHash = !isDevelopment && enableChunkHash;
84
- let plugins = [new _caseSensitivePathsWebpackPlugin.default(), new _webpack.default.IgnorePlugin(/^\.\/locale$/, /moment$/), new _webpack.default.DefinePlugin({
84
+ const plugins = [new _caseSensitivePathsWebpackPlugin.default(), new _webpack.default.IgnorePlugin(/^\.\/locale$/, /moment$/), new _webpack.default.DefinePlugin({
85
85
  __TEST__: false,
86
86
  __DEVELOPMENT__: false,
87
87
  __LOCAL_PRODUCTION__: isDevelopment,
@@ -108,11 +108,11 @@ let getProdPlugins = (options, publicPath = '') => {
108
108
  }
109
109
 
110
110
  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.
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.
116
116
  */
117
117
 
118
118
  const i18nFileNameTemplate = 'i18n-chunk/[locale]/[name].[chunkhash].i18n.js';
@@ -132,7 +132,7 @@ let getProdPlugins = (options, publicPath = '') => {
132
132
  propertiesFolder: i18n.propertiesFolder
133
133
  }));
134
134
  } else {
135
- let i18nPath = _path.default.join(process.cwd(), context, 'i18n');
135
+ const i18nPath = _path.default.join(process.cwd(), context, 'i18n');
136
136
 
137
137
  if (_fs.default.existsSync(i18nPath)) {
138
138
  plugins.push(new _copyWebpackPlugin.default([{
@@ -148,21 +148,16 @@ let getProdPlugins = (options, publicPath = '') => {
148
148
  to: `./${tpFolder}/`,
149
149
  toType: 'dir'
150
150
  }]));
151
+ (0, _configHtmlWebpackPlugins.configHtmlWebpackPlugins)(plugins, {
152
+ enableChunkHash,
153
+ folder,
154
+ inject,
155
+ minify: minifyHtmlOptions,
156
+ crossorigin,
157
+ hasEFC
158
+ });
151
159
 
152
160
  if (hasEFC) {
153
- plugins.push(new _htmlWebpackPlugin.default({
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
161
  plugins.push(new _plugins.EFCPlugin({
167
162
  isDevelopment,
168
163
  serverUrl: publicPath,
@@ -175,19 +170,6 @@ let getProdPlugins = (options, publicPath = '') => {
175
170
  localeAttr: efcLocaleAttr,
176
171
  cdnVariableName: cdnMapping.isCdnEnabled ? cdnMapping.variableName : null
177
172
  }));
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
173
  }
192
174
 
193
175
  plugins.push(new _plugins.I18NInjectIntoIndexPlugin({
@@ -201,7 +183,7 @@ let getProdPlugins = (options, publicPath = '') => {
201
183
  }));
202
184
 
203
185
  if (publicPaths && !isDevelopment && !cdnMapping.isCdnEnabled) {
204
- let {
186
+ const {
205
187
  callback
206
188
  } = publicPaths;
207
189
  plugins.push(callback ? new _plugins.PublicPathCallbackPlugin({
@@ -255,7 +237,7 @@ let getProdPlugins = (options, publicPath = '') => {
255
237
  }
256
238
 
257
239
  if (!isDevelopment && serviceWorker.enableSw) {
258
- let {
240
+ const {
259
241
  filePath,
260
242
  fileName = 'sw.js',
261
243
  exitPath = '/',
@@ -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}`;