@zohodesk/react-cli 0.0.1-test.148.2 → 1.0.0-exp.1

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 (180) hide show
  1. package/.eslintignore +7 -7
  2. package/.eslintrc.js +180 -183
  3. package/.prettierrc +6 -0
  4. package/{CHANGELOG.md → CHANGELOG-fz.md} +0 -0
  5. package/Changelog.md +1019 -0
  6. package/README.md +1161 -678
  7. package/bin/cli.js +483 -392
  8. package/docs/CustomChunks.md +26 -0
  9. package/docs/DevServerPort.md +39 -0
  10. package/docs/DevStart.md +18 -0
  11. package/docs/HoverActive.md +12 -0
  12. package/docs/InstallNode.md +28 -0
  13. package/docs/SelectorWeight.md +6 -0
  14. package/docs/TODOS.md +10 -0
  15. package/docs/ValueReplacer.md +60 -0
  16. package/docs/VariableConversion.md +724 -0
  17. package/docs/warnings_while_install.txt +35 -0
  18. package/files/eslintrc.js +62 -62
  19. package/files/prettierrc.js +3 -3
  20. package/lib/common/getEntries.js +9 -6
  21. package/lib/common/index.js +6 -6
  22. package/lib/common/splitChunks.js +60 -12
  23. package/lib/common/sslcertUpdater.js +59 -0
  24. package/lib/common/testPattern.js +69 -0
  25. package/lib/common/valueReplacer.js +55 -0
  26. package/lib/configs/jest.config.js +18 -8
  27. package/lib/configs/libAlias.js +38 -0
  28. package/lib/configs/resolvers.js +40 -0
  29. package/lib/configs/webpack.css.umd.config.js +4 -4
  30. package/lib/configs/webpack.dev.config.js +59 -54
  31. package/lib/configs/webpack.docs.config.js +74 -59
  32. package/lib/configs/webpack.docs1.config.js +122 -0
  33. package/lib/configs/webpack.impact.config.js +54 -50
  34. package/lib/configs/webpack.prod.config.js +72 -47
  35. package/lib/constants.js +31 -0
  36. package/lib/hooks/docsEntry.js +18 -0
  37. package/lib/jest/preProcessors/cssPreprocessor.js +16 -7
  38. package/lib/loaderUtils/configsAssetsLoaders.js +117 -0
  39. package/lib/loaderUtils/getCSSLoaders.js +89 -21
  40. package/lib/loaderUtils/index.js +4 -4
  41. package/lib/loaderUtils/windowsModification.js +11 -0
  42. package/lib/loaders/fileBountryLoader.js +17 -0
  43. package/lib/loaders/scriptInstrumentLoader.js +2 -2
  44. package/lib/loaders/selectorMappingLoader.js +75 -0
  45. package/lib/loaders/workerLoader.js +9 -9
  46. package/lib/pluginUtils/configHtmlWebpackPlugins.js +60 -0
  47. package/lib/pluginUtils/getDevPlugins.js +71 -45
  48. package/lib/pluginUtils/getDocsPlugins.js +21 -10
  49. package/lib/pluginUtils/getLibraryImactPlugins.js +23 -0
  50. package/lib/pluginUtils/getProdPlugins.js +75 -58
  51. package/lib/pluginUtils/index.js +12 -12
  52. package/lib/plugins/CdnChangePlugin.js +16 -2
  53. package/lib/plugins/EFCPlugin.js +52 -20
  54. package/lib/plugins/EFCPlugin.md +6 -0
  55. package/lib/plugins/EFCTemplatePlugin.js +151 -0
  56. package/lib/plugins/I18NInjectIntoIndexPlugin.js +4 -4
  57. package/lib/plugins/I18nSplitPlugin/I18nDownlodLogic.js +38 -38
  58. package/lib/plugins/I18nSplitPlugin/I18nFilesEmitter.js +30 -30
  59. package/lib/plugins/I18nSplitPlugin/I18nKeysIdentifer.js +8 -8
  60. package/lib/plugins/I18nSplitPlugin/I18nSplit.md +95 -86
  61. package/lib/plugins/I18nSplitPlugin/README.md +25 -25
  62. package/lib/plugins/I18nSplitPlugin/index.js +57 -57
  63. package/lib/plugins/I18nSplitPlugin/utils/hashUtils.js +2 -2
  64. package/lib/plugins/I18nSplitPlugin/utils/propertiesUtils.js +1 -1
  65. package/lib/plugins/ManifestPlugin.js +8 -0
  66. package/lib/plugins/RequireVariablePublicPlugin.js +30 -0
  67. package/lib/plugins/ResourceHintsPlugin.js +17 -17
  68. package/lib/plugins/RtlSplitPlugin/RtlCssPlugin.js +11 -7
  69. package/lib/plugins/RtlSplitPlugin/RtrSplit.md +30 -0
  70. package/lib/plugins/SelectorPlugin.js +97 -0
  71. package/lib/plugins/ServiceWorkerPlugin.js +13 -9
  72. package/lib/plugins/SourceMapHookPlugin.js +9 -3
  73. package/lib/plugins/TPHashMappingPlugin.js +4 -4
  74. package/lib/plugins/VariableConversionCollector.js +352 -0
  75. package/lib/plugins/composeCommonPlugin.js +30 -0
  76. package/lib/plugins/index.js +36 -36
  77. package/lib/plugins/libraryImpactPlugin.js +14 -2
  78. package/lib/postcss-plugins/{ExcludeRTLPlugin.js → ExcludePlugin.js} +1 -1
  79. package/lib/postcss-plugins/RTLSplitPlugin.js +36 -32
  80. package/lib/postcss-plugins/ValueReplacer.js +46 -0
  81. package/lib/postcss-plugins/__test__/hoverActivePlugin.spec.js +22 -0
  82. package/lib/postcss-plugins/__test__/test1Input.css +39 -0
  83. package/lib/postcss-plugins/__test__/test1Output.css +39 -0
  84. package/lib/postcss-plugins/hoverActivePlugin.js +389 -0
  85. package/lib/postcss-plugins/variableModificationPlugin/ErrorHandler.js +60 -0
  86. package/lib/postcss-plugins/variableModificationPlugin/index.js +307 -0
  87. package/lib/postcss-plugins/variableModifier.js +244 -0
  88. package/lib/schemas/index.js +174 -11
  89. package/lib/servers/devBuild.js +102 -0
  90. package/lib/servers/docsServerCore.js +16 -18
  91. package/lib/servers/getCliPath.js +28 -0
  92. package/lib/servers/httpsOptions.js +49 -0
  93. package/lib/servers/nowatchserver.js +206 -0
  94. package/lib/servers/server.js +114 -82
  95. package/lib/sh/pre-commit.sh +34 -34
  96. package/lib/sh/reportPublish.sh +45 -45
  97. package/lib/templates/linterConstant.js +1 -1
  98. package/lib/utils/buildstats.html +148 -148
  99. package/lib/utils/cssClassNameGenerate.js +9 -2
  100. package/lib/utils/cssURLReplacer.js +30 -43
  101. package/lib/utils/getCurrentBranch.js +1 -1
  102. package/lib/utils/getDependenciesImpactList.js +14 -12
  103. package/lib/utils/getFileType.js +49 -0
  104. package/lib/utils/getOptions.js +118 -10
  105. package/lib/utils/index.js +44 -20
  106. package/lib/utils/jsonHelper.js +12 -3
  107. package/lib/utils/reinstallDependencies.js +1 -1
  108. package/lib/utils/repoClone.js +16 -4
  109. package/lib/utils/resultSchema.json +73 -73
  110. package/lib/utils/rtl.js +19 -2
  111. package/lib/utils/useExitCleanup.js +55 -0
  112. package/npm8.md +9 -0
  113. package/package.json +121 -142
  114. package/postpublish.js +8 -0
  115. package/result.json +1 -0
  116. package/templates/app/.eslintrc.js +140 -140
  117. package/templates/app/README.md +12 -12
  118. package/templates/app/app/index.html +24 -24
  119. package/templates/app/app/properties/ApplicationResources_en_US.properties +1 -1
  120. package/templates/app/app/properties/i18nkeys.json +3 -3
  121. package/templates/app/docs/all.html +69 -69
  122. package/templates/app/mockapi/index.js +18 -18
  123. package/templates/app/package.json +37 -37
  124. package/templates/app/src/actions/SampleActions/index.js +37 -37
  125. package/templates/app/src/actions/index.js +65 -65
  126. package/templates/app/src/appUrls.js +19 -19
  127. package/templates/app/src/components/Alert/Alert.js +134 -134
  128. package/templates/app/src/components/Alert/Alert.module.css +79 -79
  129. package/templates/app/src/components/FreezeLayer/FreezeLayer.css +37 -37
  130. package/templates/app/src/components/FreezeLayer/FreezeLayer.js +84 -84
  131. package/templates/app/src/components/Sample/Sample.module.css +11 -11
  132. package/templates/app/src/components/Sample/SampleList.js +61 -61
  133. package/templates/app/src/components/Slider/Slider.css +41 -41
  134. package/templates/app/src/components/Slider/Slider.js +55 -55
  135. package/templates/app/src/containers/AlertContainer/index.js +15 -15
  136. package/templates/app/src/containers/AppContainer/index.js +96 -96
  137. package/templates/app/src/containers/AppContainer/index.module.css +27 -27
  138. package/templates/app/src/containers/CustomMatch/index.js +65 -65
  139. package/templates/app/src/containers/DevTools/index.js +10 -10
  140. package/templates/app/src/containers/Header/index.js +67 -67
  141. package/templates/app/src/containers/Header/index.module.css +43 -43
  142. package/templates/app/src/containers/Redirect/index.js +63 -63
  143. package/templates/app/src/containers/Redirector/index.js +47 -47
  144. package/templates/app/src/containers/SampleListContainer/ListContainer.js +42 -42
  145. package/templates/app/src/containers/SampleListContainer/ListContainer.module.css +3 -3
  146. package/templates/app/src/historyChange.js +5 -5
  147. package/templates/app/src/index.html +10 -10
  148. package/templates/app/src/index.js +24 -24
  149. package/templates/app/src/middleware/PromiseMiddleware.js +59 -59
  150. package/templates/app/src/reducers/alertData.js +11 -11
  151. package/templates/app/src/reducers/index.js +6 -6
  152. package/templates/app/src/reducers/samples.js +19 -19
  153. package/templates/app/src/store/configureStore.dev.js +51 -51
  154. package/templates/app/src/store/configureStore.js +5 -5
  155. package/templates/app/src/store/configureStore.prod.js +26 -26
  156. package/templates/app/src/util/Common.js +5 -5
  157. package/templates/app/src/util/RequestAPI.js +132 -132
  158. package/templates/docs/a.html +13 -0
  159. package/templates/docs/all.html +249 -249
  160. package/templates/docs/component.html +178 -178
  161. package/templates/docs/components.html +221 -221
  162. package/templates/docs/css/b.min.css +6 -6
  163. package/templates/docs/css/component.css +42 -42
  164. package/templates/docs/css/componentTest.css +6 -6
  165. package/templates/docs/css/hopscotch.css +585 -585
  166. package/templates/docs/css/style.css +1022 -1022
  167. package/templates/docs/docsEntry.js +14 -0
  168. package/templates/docs/docsRoot.js +3 -0
  169. package/templates/docs/impactReportTemplate.html +154 -154
  170. package/templates/docs/index.html +1501 -1493
  171. package/templates/docs/js/active-line.js +72 -72
  172. package/templates/docs/js/b.min.js +7 -7
  173. package/templates/docs/js/codemirror.js +9680 -9680
  174. package/templates/docs/js/designTokens.js +334 -334
  175. package/templates/docs/js/j.min.js +4 -4
  176. package/templates/docs/js/javascript.js +874 -874
  177. package/templates/docs/js/matchbrackets.js +145 -145
  178. package/unittest/index.html +37 -0
  179. package/cert/cert.pem +0 -105
  180. package/cert/key.pem +0 -30
@@ -0,0 +1,75 @@
1
+ "use strict";
2
+
3
+ var _path = _interopRequireDefault(require("path"));
4
+
5
+ var _fs = _interopRequireDefault(require("fs"));
6
+
7
+ var _utils = require("../utils");
8
+
9
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
10
+
11
+ let options = (0, _utils.getOptions)();
12
+ const {
13
+ cssSelectorZipPath
14
+ } = options.impactService;
15
+
16
+ const zipname = _path.default.parse(cssSelectorZipPath).name; // console.log({ cssSelectorZipPath, zipname });
17
+ // TODO:NOTE: need to check about .. path related files creation
18
+ // for now no css files have given form react-cli need to make sure about it.
19
+
20
+
21
+ let zippath = _path.default.join(process.cwd(), cssSelectorZipPath);
22
+
23
+ if (_fs.default.existsSync(_path.default.join(process.cwd(), cssSelectorZipPath))) {
24
+ _fs.default.rmSync(zippath);
25
+
26
+ console.log('zip file deleted', zippath); // fs.rmSync(zippath, {force:true})
27
+ // console.log('created folder ==> ', dpath);
28
+ } // const minicssComment =
29
+ // '// extracted by mini-css-extract-plugin\n';
30
+
31
+
32
+ const startStr = '// extracted by mini-css-extract-plugin\n' + 'module.exports = ';
33
+
34
+ module.exports = function (source) {
35
+ const {
36
+ rootContext,
37
+ resourcePath
38
+ } = this;
39
+
40
+ const relativePath = _path.default.relative(rootContext, resourcePath);
41
+
42
+ let fpath = _path.default.join(rootContext, zipname, relativePath);
43
+
44
+ let originalpath = _path.default.join(rootContext, relativePath);
45
+
46
+ if (relativePath.startsWith('..')) {
47
+ throw `unexpected path ${relativePath}`;
48
+ }
49
+
50
+ let dpath = fpath.slice(0, fpath.lastIndexOf(_path.default.sep));
51
+
52
+ if (!_fs.default.existsSync(originalpath)) {
53
+ throw `originalpath not exixt ${originalpath}`;
54
+ }
55
+
56
+ if (!_fs.default.existsSync(dpath)) {
57
+ _fs.default.mkdirSync(dpath, {
58
+ recursive: true
59
+ });
60
+ }
61
+
62
+ let jsonStr = '{}';
63
+
64
+ if (source.startsWith(startStr)) {
65
+ // source will be like
66
+ // `// extracted by mini-css-extract-plugin\nmodule.exports = {"app":"zd-app"};`
67
+ jsonStr = source.slice(startStr.length, -1);
68
+ }
69
+
70
+ _fs.default.writeFileSync(`${fpath}_map`, jsonStr);
71
+
72
+ _fs.default.writeFileSync(fpath, _fs.default.readFileSync(originalpath));
73
+
74
+ return source;
75
+ };
@@ -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,60 @@
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
+ mainEntryHtmlFile,
33
+ folder,
34
+ inject,
35
+ crossorigin,
36
+ hasEFC,
37
+ minify: minifyHtmlOptions = false
38
+ }) {
39
+ const optionsHtmlWebpack = {
40
+ chunksSortMode: 'none',
41
+ filename: enableChunkHash ? 'index.[templatehash:20].html' : 'index.html',
42
+ template: _path.default.join(process.cwd(), folder, mainEntryHtmlFile),
43
+ minify: minifyHtmlOptions === true ? defaultHTMLMiniFyOption : minifyHtmlOptions === null ? false : minifyHtmlOptions,
44
+ // : typeof minifyHtmlOptions === 'object'
45
+ // ? minifyHtmlOptions
46
+ // : minifyHtmlOptions,,
47
+ templateParameters: _common.templateParameters,
48
+ scriptLoading: 'defer',
49
+ inject: inject
50
+ };
51
+
52
+ if (hasEFC) {
53
+ optionsHtmlWebpack.excludeChunks = ['efc', 'widget'];
54
+ }
55
+
56
+ plugins.push(new _htmlWebpackPlugin.default(optionsHtmlWebpack));
57
+ crossorigin && plugins.push(new _htmlWebpackInjectAttributesPlugin.default({
58
+ crossorigin: 'anonymous'
59
+ }));
60
+ }
@@ -15,40 +15,53 @@ 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
18
  var _I18nSplitPlugin = _interopRequireDefault(require("../plugins/I18nSplitPlugin"));
21
19
 
20
+ var _RequireVariablePublicPlugin = _interopRequireDefault(require("../plugins/RequireVariablePublicPlugin"));
21
+
22
22
  var _copyWebpackPlugin = _interopRequireDefault(require("copy-webpack-plugin"));
23
23
 
24
24
  var _webpack = _interopRequireDefault(require("webpack"));
25
25
 
26
26
  var _plugins = require("../plugins");
27
27
 
28
- var _common = require("../common");
29
-
30
28
  var _RtlCssPlugin = require("../plugins/RtlSplitPlugin/RtlCssPlugin");
31
29
 
30
+ var _VariableConversionCollector = _interopRequireDefault(require("../plugins/VariableConversionCollector"));
31
+
32
+ var _SelectorPlugin = _interopRequireDefault(require("../plugins/SelectorPlugin"));
33
+
34
+ var _configHtmlWebpackPlugins = require("./configHtmlWebpackPlugins");
35
+
32
36
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
33
37
 
34
- let getDevPlugins = (options, publicPath) => {
35
- let {
38
+ // import { windowsModification } from '../loaderUtils/windowsModification';
39
+ const getDevPlugins = (options, publicPath) => {
40
+ const {
36
41
  app: {
37
42
  tpFolder,
38
43
  folder,
44
+ mainEntryHtmlFile,
39
45
  instrumentScript,
46
+ devCssFileBountry,
40
47
  context,
41
48
  hasEFC: prevOptionForEnableEFC,
42
49
  hasShadowDOM,
50
+ cssVariableReplacementConfig,
51
+ plugins: pluginObject,
52
+ // exclude,
53
+ selectorWeightConfig,
43
54
  server: {
44
55
  mode
45
56
  },
46
57
  htmlTemplate: {
47
58
  inject
48
- }
59
+ },
60
+ crossorigin
49
61
  },
50
62
  efc: {
51
63
  hasEFC: newOptionForEnableEFC,
64
+ templateFilePath,
52
65
  nameScope: efcNameSpace,
53
66
  localeAttr: efcLocaleAttr
54
67
  },
@@ -59,9 +72,10 @@ let getDevPlugins = (options, publicPath) => {
59
72
  unusedFiles
60
73
  } = options;
61
74
  const hasEFC = newOptionForEnableEFC || prevOptionForEnableEFC;
62
- const cssLTRFileNameTempalte = 'css/[name].ltr.css';
63
- const cssRTLFileNameTempalte = 'css/[name].rtl.css';
64
- let plugins = [new _plugins.CleanUpStatsPlugin(), new _caseSensitivePathsWebpackPlugin.default(), new _webpack.default.IgnorePlugin(/^\.\/domain$/, /moment$/), new _webpack.default.DefinePlugin({
75
+ const cssLTRFileNameTempalte = enableRTLSplit ? 'css/[name].ltr.css' : 'css/[name].css';
76
+ const cssRTLFileNameTempalte = 'css/[name].rtl.css'; // const selectorWeightLocal = windowsModification(exclude.selectorWeight);
77
+
78
+ const pluginsArr = [new _plugins.CleanUpStatsPlugin(), new _caseSensitivePathsWebpackPlugin.default(), new _webpack.default.IgnorePlugin(/^\.\/domain$/, /moment$/), new _webpack.default.DefinePlugin({
65
79
  __CLIENT__: true,
66
80
  __TEST__: false,
67
81
  __SERVER__: false,
@@ -79,9 +93,10 @@ let getDevPlugins = (options, publicPath) => {
79
93
  }), new _plugins.ResourceHintsPlugin()];
80
94
 
81
95
  if (enableRTLSplit) {
82
- plugins.push(new _RtlCssPlugin.RtlCssPlugin({
96
+ pluginsArr.push(new _RtlCssPlugin.RtlCssPlugin({
83
97
  templateLabel: options.css.templateLabel,
84
98
  dirVarName: options.css.dirVarName,
99
+ disableMiniFiySelector: options.css.disableMiniFiySelector,
85
100
  // config: {},
86
101
  // sourcemap: true,
87
102
  filename: cssRTLFileNameTempalte
@@ -89,24 +104,24 @@ let getDevPlugins = (options, publicPath) => {
89
104
  }
90
105
 
91
106
  if (unusedFiles.enable) {
92
- plugins.push(new _plugins.UnusedFilesFindPlugin(Object.assign(unusedFiles, {
107
+ pluginsArr.push(new _plugins.UnusedFilesFindPlugin(Object.assign(unusedFiles, {
93
108
  origin: _path.default.join(process.cwd(), folder)
94
109
  })));
95
110
  }
96
111
 
97
112
  const i18nManifestFileName = 'i18n-manifest.json';
98
- /**
99
- * NOTE:
100
- * this file name ext .i18n.js added
101
- * Because, in service worker they maintain cache as file name based
102
- * So, to make differce we added .i18n.js ext.
113
+ /**
114
+ * NOTE:
115
+ * this file name ext .i18n.js added
116
+ * Because, in service worker they maintain cache as file name based
117
+ * So, to make differce we added .i18n.js ext.
103
118
  */
104
119
 
105
120
  const i18nFileNameTemplate = 'i18n-chunk/[locale]/[name].i18n.js';
106
121
  const i18nPublicPath = publicPath || '';
107
122
 
108
123
  if (i18n.chunkSplitEnable) {
109
- plugins.push(new _I18nSplitPlugin.default({
124
+ pluginsArr.push(new _I18nSplitPlugin.default({
110
125
  jsResource: i18n.jsResource,
111
126
  localeVarName: i18n.localeVarName,
112
127
  jsonpFunc: i18n.jsonpFunc,
@@ -118,10 +133,10 @@ let getDevPlugins = (options, publicPath) => {
118
133
  propertiesFolder: i18n.propertiesFolder
119
134
  }));
120
135
  } else {
121
- let i18nPath = _path.default.join(process.cwd(), context, 'i18n');
136
+ const i18nPath = _path.default.join(process.cwd(), context, 'i18n');
122
137
 
123
138
  if (_fs.default.existsSync(i18nPath)) {
124
- plugins.push(new _copyWebpackPlugin.default([{
139
+ pluginsArr.push(new _copyWebpackPlugin.default([{
125
140
  from: `${i18nPath}/`,
126
141
  to: './i18n/[name].[ext]',
127
142
  toType: 'template'
@@ -129,29 +144,30 @@ let getDevPlugins = (options, publicPath) => {
129
144
  }
130
145
  }
131
146
 
132
- tpFolder && plugins.push(new _copyWebpackPlugin.default([{
147
+ tpFolder && pluginsArr.push(new _copyWebpackPlugin.default([{
133
148
  from: `${_path.default.join(process.cwd(), context, tpFolder)}/`,
134
149
  to: `./${tpFolder}/`,
135
150
  toType: 'dir'
136
151
  }]));
137
- plugins.push(new _lodashWebpackPlugin.default({
152
+ pluginsArr.push(new _lodashWebpackPlugin.default({
138
153
  collections: true,
139
154
  shorthands: true
140
155
  }));
156
+ (0, _configHtmlWebpackPlugins.configHtmlWebpackPlugins)(pluginsArr, {
157
+ enableChunkHash: false,
158
+ mainEntryHtmlFile,
159
+ folder,
160
+ minify: false,
161
+ inject,
162
+ crossorigin,
163
+ hasEFC
164
+ });
141
165
 
142
166
  if (hasEFC) {
143
- plugins.push(new _htmlWebpackPlugin.default({
144
- chunksSortMode: 'none',
145
- filename: 'index.html',
146
- template: _path.default.join(process.cwd(), folder, 'index.html'),
147
- excludeChunks: ['efc', 'widget'],
148
- templateParameters: _common.templateParameters,
149
- scriptLoading: 'defer',
150
- inject: inject
151
- }));
152
- plugins.push(new _plugins.EFCPlugin({
167
+ pluginsArr.push(new _plugins.EFCPlugin({
153
168
  isDevelopment: true,
154
169
  i18nManifestFileName,
170
+ templateFilePath,
155
171
  i18nFileNameTemplate,
156
172
  serverUrl: publicPath,
157
173
  entryPointName: 'efc',
@@ -159,18 +175,9 @@ let getDevPlugins = (options, publicPath) => {
159
175
  localeAttr: efcLocaleAttr // outputFile: 'zohodesk-efc-sdk-latest.js',
160
176
 
161
177
  }));
162
- } else {
163
- plugins.push(new _htmlWebpackPlugin.default({
164
- chunksSortMode: 'none',
165
- filename: 'index.html',
166
- template: _path.default.join(process.cwd(), folder, 'index.html'),
167
- templateParameters: _common.templateParameters,
168
- scriptLoading: 'defer',
169
- inject: inject
170
- }));
171
178
  }
172
179
 
173
- plugins.push(new _plugins.I18NInjectIntoIndexPlugin({
180
+ pluginsArr.push(new _plugins.I18NInjectIntoIndexPlugin({
174
181
  publicPath: i18nPublicPath,
175
182
  isDevelopment: true,
176
183
  templateLabel: i18n.templateLabel || '{{--user-locale}}',
@@ -178,9 +185,28 @@ let getDevPlugins = (options, publicPath) => {
178
185
  i18nManifestFileName,
179
186
  mainChunkName: 'main'
180
187
  }));
181
- instrumentScript && plugins.push(new _plugins.ScriptInstrumentPlugin());
182
- hasShadowDOM && plugins.push(new _plugins.ShadowDOMSupportPlugin());
183
- return plugins.filter(Boolean);
188
+ instrumentScript && pluginsArr.push(new _plugins.ScriptInstrumentPlugin());
189
+ hasShadowDOM && pluginsArr.push(new _plugins.ShadowDOMSupportPlugin());
190
+
191
+ if (devCssFileBountry) {
192
+ pluginsArr.push(new _RequireVariablePublicPlugin.default({
193
+ requireFuncName: 'require'
194
+ }));
195
+ }
196
+
197
+ if (pluginObject.cssVariableReplacement) {
198
+ pluginsArr.push(new _VariableConversionCollector.default({
199
+ cssVariableReplacementConfig
200
+ }));
201
+ }
202
+
203
+ if (pluginObject.selectorWeight) {
204
+ pluginsArr.push(new _SelectorPlugin.default({
205
+ selectorWeightConfig
206
+ }));
207
+ }
208
+
209
+ return pluginsArr.filter(Boolean);
184
210
  };
185
211
 
186
212
  var _default = getDevPlugins;
@@ -9,37 +9,39 @@ var _caseSensitivePathsWebpackPlugin = _interopRequireDefault(require("case-sens
9
9
 
10
10
  var _miniCssExtractPlugin = _interopRequireDefault(require("mini-css-extract-plugin"));
11
11
 
12
+ var _htmlWebpackPlugin = _interopRequireDefault(require("html-webpack-plugin"));
13
+
12
14
  var _webpack = _interopRequireDefault(require("webpack"));
13
15
 
14
16
  var _path = _interopRequireDefault(require("path"));
15
17
 
16
18
  var _plugins = require("../plugins");
17
19
 
20
+ var _fs = require("fs");
21
+
18
22
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
19
23
 
20
- let getDocsPlugins = (isSSTest, options) => {
21
- let {
24
+ // isForLibraryImpact this variable for now only used in getLibraryImactPlugins.
25
+ // So you gona use it please check with that function as well
26
+ const getDocsPlugins = (isSSTest, options, isForLibraryImpact = false) => {
27
+ const {
22
28
  app: {
23
29
  folder
24
30
  },
25
31
  unusedFiles
26
32
  } = options;
27
- let plugins = [new _plugins.CleanUpStatsPlugin(), new _caseSensitivePathsWebpackPlugin.default(), new _webpack.default.ProvidePlugin({
33
+ const plugins = [new _plugins.CleanUpStatsPlugin(), new _caseSensitivePathsWebpackPlugin.default(), new _webpack.default.ProvidePlugin({
28
34
  React: 'react'
29
35
  }), new _webpack.default.DefinePlugin({
30
36
  __TEST__: false,
31
37
  __DEVELOPMENT__: true,
32
38
  __DOCS__: true
33
- }), ...(isSSTest ? [new _plugins.ModuleStatsPlugin({
39
+ }), !isForLibraryImpact && new _plugins.ModuleStatsPlugin({
34
40
  filename: 'js/moduleStats.js'
35
- })] : [new _plugins.LibraryImpactPlugin({
36
- filename: 'js/libraryImpact.js'
37
- })]), new _miniCssExtractPlugin.default({
41
+ }), new _miniCssExtractPlugin.default({
38
42
  filename: 'css/[name].css',
39
43
  chunkFilename: 'css/[name].css'
40
- }), new _plugins.UnusedFilesFindPlugin(Object.assign(unusedFiles, {
41
- origin: _path.default.join(process.cwd(), folder)
42
- }))].filter(Boolean);
44
+ })].filter(Boolean);
43
45
 
44
46
  if (unusedFiles.enable) {
45
47
  plugins.push(new _plugins.UnusedFilesFindPlugin(Object.assign(unusedFiles, {
@@ -49,6 +51,15 @@ let getDocsPlugins = (isSSTest, options) => {
49
51
  })));
50
52
  }
51
53
 
54
+ const tempHTML = _path.default.join(__dirname, '../../templates/docs/a.html');
55
+
56
+ console.log('tempHTML', tempHTML, (0, _fs.existsSync)(tempHTML));
57
+ plugins.push(new _htmlWebpackPlugin.default({
58
+ filename: 'out.html',
59
+ template: tempHTML // scriptLoading: 'defer',
60
+ // inject: false
61
+
62
+ }));
52
63
  return plugins;
53
64
  };
54
65
 
@@ -0,0 +1,23 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.default = getLibraryImactPlugins;
7
+
8
+ var _libraryImpactPlugin = _interopRequireDefault(require("../plugins/libraryImpactPlugin"));
9
+
10
+ var _getDocsPlugins = _interopRequireDefault(require("./getDocsPlugins"));
11
+
12
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
13
+
14
+ // import ModuleStatsPlugin from '../plugins/ModuleStatsPlugin';
15
+ function getLibraryImactPlugins(options) {
16
+ let plugins = (0, _getDocsPlugins.default)(false, options, true); // for performance But for furture maintanablity we adding isForLibraryImpact in getDocsPlugin
17
+ // plugins.filter(plugin => !(plugin instanceof ModuleStatsPlugin));
18
+
19
+ plugins.push(new _libraryImpactPlugin.default({
20
+ filename: 'js/libraryImpact.js'
21
+ }));
22
+ return plugins;
23
+ }