@zohodesk/client_build_tool 0.0.11-exp.15.4 → 0.0.11-exp.16.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.
- package/README.md +102 -0
- package/README_backup.md +100 -0
- package/docs/DYNAMIC_TEMPLATE_EXAMPLE.md +129 -0
- package/docs/I18N_SINGLE_FILE_MODE.md +126 -0
- package/example-single-file-config.js +59 -0
- package/lib/allCommandsConfigs.js +2 -7
- package/lib/commands/build/commandExecutor.js +1 -5
- package/lib/commands/build/config.js +2 -3
- package/lib/commands/build/optionsProcessor.js +2 -5
- package/lib/commands/build/preProcessor.js +0 -2
- package/lib/commands/buildEs/commandExecutor.js +0 -5
- package/lib/commands/buildEs/config.js +2 -3
- package/lib/commands/buildEs/preProcessor.js +0 -2
- package/lib/commands/buildLib/commandExecutor.js +0 -5
- package/lib/commands/buildLib/config.js +2 -3
- package/lib/commands/buildLib/preProcessor.js +0 -2
- package/lib/commands/mockserver/commandExecutor.js +2 -9
- package/lib/commands/mockserver/config.js +2 -3
- package/lib/commands/pre_process/commandExecutor.js +0 -2
- package/lib/commands/pre_process/config.js +2 -3
- package/lib/commands/start/commandExecutor.js +0 -2
- package/lib/commands/start/config.js +2 -3
- package/lib/commands/start/optionsProcessor.js +2 -4
- package/lib/commands/start/preProcessor.js +0 -2
- package/lib/commands/template/commandExecutor.js +0 -7
- package/lib/commands/template/config.js +2 -3
- package/lib/commands/version/commandExecutor.js +0 -3
- package/lib/commands/version/config.js +2 -3
- package/lib/commandsRouter.js +5 -21
- package/lib/index.js +0 -2
- package/lib/logger.js +0 -5
- package/lib/schemas/applyValuesToSchema/index.js +0 -8
- package/lib/schemas/applyValuesToSchema/isObject.js +0 -1
- package/lib/schemas/applyValuesToSchema/isValid.js +0 -2
- package/lib/schemas/cliArgsToObject.js +2 -6
- package/lib/schemas/defaultConfigValues.js +21 -12
- package/lib/schemas/defaultConfigValuesOnly.js +4 -7
- package/lib/schemas/deprecatedOptionsHandler.js +7 -16
- package/lib/schemas/getNpmVersion.js +0 -5
- package/lib/schemas/giveDefaultValue.js +0 -3
- package/lib/schemas/npmConfigToObject.js +2 -5
- package/lib/schemas/readOptions.js +10 -30
- package/lib/schemas/readOptionsForConfigFile.js +2 -12
- package/lib/shared/babel/addDefaultPlugins.js +0 -2
- package/lib/shared/babel/babelWebConfig.js +1 -10
- package/lib/shared/babel/babel_plugins/removeAttributesPlugin.js +0 -4
- package/lib/shared/babel/getBabelPlugin.js +2 -7
- package/lib/shared/babel/runBabelForJSFile.js +1 -4
- package/lib/shared/babel/runBabelForTsFile.js +1 -5
- package/lib/shared/bundler/webpack/common/decidePublicPath.js +0 -5
- package/lib/shared/bundler/webpack/common/libAlias.js +3 -3
- package/lib/shared/bundler/webpack/common/modeUtils.js +0 -5
- package/lib/shared/bundler/webpack/common/nameTemplates.js +11 -18
- package/lib/shared/bundler/webpack/common/resourceBasedPublicPath.js +2 -3
- package/lib/shared/bundler/webpack/configCustomLoaders.js +0 -1
- package/lib/shared/bundler/webpack/cssLoaders.js +0 -2
- package/lib/shared/bundler/webpack/custom_plugins/BundleIntegrityReport/index.js +1 -20
- package/lib/shared/bundler/webpack/custom_plugins/CdnChangePlugin/index.js +20 -25
- package/lib/shared/bundler/webpack/custom_plugins/CdnChangePlugin/webpackCustomJsUrlLoader.js +4 -9
- package/lib/shared/bundler/webpack/custom_plugins/CustomScriptLoadingPlugin.js +3 -23
- package/lib/shared/bundler/webpack/custom_plugins/EFCTemplatePlugin.js +8 -19
- package/lib/shared/bundler/webpack/custom_plugins/I18nNumericIndexPlugin/I18nGroupRuntimeModule.js +2 -6
- package/lib/shared/bundler/webpack/custom_plugins/I18nNumericIndexPlugin/I18nNumericIndexHtmlInjectorPlugin.js +81 -0
- package/lib/shared/bundler/webpack/custom_plugins/I18nNumericIndexPlugin/I18nNumericIndexPlugin.js +135 -60
- package/lib/shared/bundler/webpack/custom_plugins/I18nNumericIndexPlugin/utils/i18nDataLoader.js +20 -26
- package/lib/shared/bundler/webpack/custom_plugins/I18nSplitPlugin/I18nFilesEmitPlugin.js +5 -26
- package/lib/shared/bundler/webpack/custom_plugins/I18nSplitPlugin/I18nKeysIdentifer.js +13 -16
- package/lib/shared/bundler/webpack/custom_plugins/I18nSplitPlugin/I18nRuntimeDealerPlugin.js +19 -53
- package/lib/shared/bundler/webpack/custom_plugins/I18nSplitPlugin/LocaleChunkAssetsStore.js +2 -17
- package/lib/shared/bundler/webpack/custom_plugins/I18nSplitPlugin/ModulesI18nKeysStore.js +0 -13
- package/lib/shared/bundler/webpack/custom_plugins/I18nSplitPlugin/constants.js +11 -21
- package/lib/shared/bundler/webpack/custom_plugins/I18nSplitPlugin/createHash.js +0 -4
- package/lib/shared/bundler/webpack/custom_plugins/I18nSplitPlugin/getI18nLoadingRuntimeModule.js +4 -14
- package/lib/shared/bundler/webpack/custom_plugins/I18nSplitPlugin/index.js +3 -13
- package/lib/shared/bundler/webpack/custom_plugins/I18nSplitPlugin/iterateModulesInChunk.js +3 -12
- package/lib/shared/bundler/webpack/custom_plugins/I18nSplitPlugin/optionsHandler.js +2 -7
- package/lib/shared/bundler/webpack/custom_plugins/I18nSplitPlugin/pathCreator.js +0 -2
- package/lib/shared/bundler/webpack/custom_plugins/I18nSplitPlugin/readI18nValues.js +2 -3
- package/lib/shared/bundler/webpack/custom_plugins/I18nSplitPlugin/templateFileName.js +2 -4
- package/lib/shared/bundler/webpack/custom_plugins/I18nSplitPlugin/templateHashHelpers.js +8 -13
- package/lib/shared/bundler/webpack/custom_plugins/I18nSplitPlugin/utils/collectI18nKeys.js +2 -14
- package/lib/shared/bundler/webpack/custom_plugins/I18nSplitPlugin/utils/getChunkModules.js +0 -1
- package/lib/shared/bundler/webpack/custom_plugins/I18nSplitPlugin/utils/hashUtils.js +1 -3
- package/lib/shared/bundler/webpack/custom_plugins/I18nSplitPlugin/utils/index.js +0 -4
- package/lib/shared/bundler/webpack/custom_plugins/I18nSplitPlugin/utils/propertiesUtils.js +5 -25
- package/lib/shared/bundler/webpack/custom_plugins/InitialHtmlPlugin.js +3 -10
- package/lib/shared/bundler/webpack/custom_plugins/ManifestJsonPlugin/addFilesNamesToManifestJson.js +1 -6
- package/lib/shared/bundler/webpack/custom_plugins/ManifestJsonPlugin/createInitialEntries.js +1 -6
- package/lib/shared/bundler/webpack/custom_plugins/ManifestJsonPlugin/createManifestJson.js +0 -6
- package/lib/shared/bundler/webpack/custom_plugins/ManifestJsonPlugin/findInitialFileNames.js +0 -1
- package/lib/shared/bundler/webpack/custom_plugins/ManifestJsonPlugin/index.js +0 -7
- package/lib/shared/bundler/webpack/custom_plugins/ManifestJsonPlugin/removeHashFromFileName.js +0 -1
- package/lib/shared/bundler/webpack/custom_plugins/ResourceHintsPlugin.js +13 -17
- package/lib/shared/bundler/webpack/custom_plugins/RtlSplitPlugin/OverwriteCssPathForRTL.js +6 -15
- package/lib/shared/bundler/webpack/custom_plugins/RtlSplitPlugin/RtlCssPlugin.js +4 -13
- package/lib/shared/bundler/webpack/custom_plugins/RtlSplitPlugin/replaceCssDirTemplate.js +4 -6
- package/lib/shared/bundler/webpack/custom_plugins/RuntimeResourceCleanup/index.js +0 -10
- package/lib/shared/bundler/webpack/custom_plugins/SelectorWeightPlugin/classHandling.js +0 -3
- package/lib/shared/bundler/webpack/custom_plugins/SelectorWeightPlugin/index.js +4 -20
- package/lib/shared/bundler/webpack/custom_plugins/SelectorWeightPlugin/selectorWeightPrefixAdder.js +10 -12
- package/lib/shared/bundler/webpack/custom_plugins/SelectorWeightPlugin/windowsModification.js +2 -3
- package/lib/shared/bundler/webpack/custom_plugins/ServiceWorkerPlugin.js +7 -20
- package/lib/shared/bundler/webpack/custom_plugins/ServiceWorkerPluginUtils.js +0 -1
- package/lib/shared/bundler/webpack/custom_plugins/SourceMapPlugin/index.js +7 -10
- package/lib/shared/bundler/webpack/custom_plugins/TPHashMappingPlugin/addHashToFilePath.js +1 -6
- package/lib/shared/bundler/webpack/custom_plugins/TPHashMappingPlugin/index.js +1 -16
- package/lib/shared/bundler/webpack/custom_plugins/UglifyCSSPlugin/index.js.js +4 -11
- package/lib/shared/bundler/webpack/custom_plugins/VariableConversionCollector/ErrorHandler.js +3 -10
- package/lib/shared/bundler/webpack/custom_plugins/VariableConversionCollector/index.js +27 -62
- package/lib/shared/bundler/webpack/custom_plugins/custom_attribute_plugin/index.js +3 -15
- package/lib/shared/bundler/webpack/custom_plugins/emitAsset.js +0 -1
- package/lib/shared/bundler/webpack/custom_plugins/getInitialAssetsFuncTemplate.js +2 -12
- package/lib/shared/bundler/webpack/custom_plugins/getInitialI18nAssetsArrayStr.js +2 -7
- package/lib/shared/bundler/webpack/defaultVendorPatternList.js +2 -6
- package/lib/shared/bundler/webpack/devtoolConfig.js +0 -1
- package/lib/shared/bundler/webpack/entryConfig.js +0 -4
- package/lib/shared/bundler/webpack/externals.js +0 -1
- package/lib/shared/bundler/webpack/getCSSLoaders.js +1 -6
- package/lib/shared/bundler/webpack/getFilenameFromModule.js +1 -5
- package/lib/shared/bundler/webpack/jsLoaders.js +6 -10
- package/lib/shared/bundler/webpack/loaderConfigs/assetLoaders.js +0 -2
- package/lib/shared/bundler/webpack/loaderConfigs/babelLoaderConfig.js +2 -3
- package/lib/shared/bundler/webpack/loaderConfigs/checkIsPatternsMatchFilename.js +3 -12
- package/lib/shared/bundler/webpack/loaderConfigs/configHtmlTemplateLoader.js +0 -1
- package/lib/shared/bundler/webpack/loaderConfigs/configPostCssLoader.js +2 -10
- package/lib/shared/bundler/webpack/loaderConfigs/configWebWorkerLoader.js +0 -2
- package/lib/shared/bundler/webpack/loaderConfigs/configsAssetsLoaders.js +0 -12
- package/lib/shared/bundler/webpack/loaderConfigs/cssClassNameGenerate.js +1 -15
- package/lib/shared/bundler/webpack/loaderConfigs/getCssLoaderOptions.js +1 -4
- package/lib/shared/bundler/webpack/loaderConfigs/i18nIdReplaceLoaderConfig.js +8 -16
- package/lib/shared/bundler/webpack/loaders/i18nIdReplaceLoader.js +22 -29
- package/lib/shared/bundler/webpack/loaders/miniCssFallBackLoader.js +2 -2
- package/lib/shared/bundler/webpack/loaders/workerLoader.js +8 -19
- package/lib/shared/bundler/webpack/optimizationConfig.js +5 -13
- package/lib/shared/bundler/webpack/outputConfig.js +1 -9
- package/lib/shared/bundler/webpack/pluginConfigs/configBundleAnalyzer.js +5 -9
- package/lib/shared/bundler/webpack/pluginConfigs/configBundleIntegrityReport.js +0 -5
- package/lib/shared/bundler/webpack/pluginConfigs/configCSSMinifierPlugin.js +4 -9
- package/lib/shared/bundler/webpack/pluginConfigs/configCdnChangePlugin.js +3 -8
- package/lib/shared/bundler/webpack/pluginConfigs/configCopyPublicFolders.js +1 -16
- package/lib/shared/bundler/webpack/pluginConfigs/configCustomAttributesPlugin.js +0 -4
- package/lib/shared/bundler/webpack/pluginConfigs/configCustomScriptLoadingStrategyPlugin.js +0 -16
- package/lib/shared/bundler/webpack/pluginConfigs/configEFCTemplatePlugin.js +0 -5
- package/lib/shared/bundler/webpack/pluginConfigs/configEnvVariables.js +0 -5
- package/lib/shared/bundler/webpack/pluginConfigs/configHtmlWebpackPlugin.js +2 -8
- package/lib/shared/bundler/webpack/pluginConfigs/configI18nIndexingPlugin.js +5 -9
- package/lib/shared/bundler/webpack/pluginConfigs/configI18nNumericHtmlInjector.js +19 -25
- package/lib/shared/bundler/webpack/pluginConfigs/configI18nNumericIndexPlugin.js +92 -0
- package/lib/shared/bundler/webpack/pluginConfigs/configI18nSplitPlugin.js +3 -9
- package/lib/shared/bundler/webpack/pluginConfigs/configIgnorePlugin.js +0 -2
- package/lib/shared/bundler/webpack/pluginConfigs/configManifestJsonPlugin.js +0 -7
- package/lib/shared/bundler/webpack/pluginConfigs/configMiniCSSExtractPlugin.js +3 -7
- package/lib/shared/bundler/webpack/pluginConfigs/configProgressPlugin.js +1 -5
- package/lib/shared/bundler/webpack/pluginConfigs/configResourceHintsPlugin.js +1 -4
- package/lib/shared/bundler/webpack/pluginConfigs/configRtlCssPlugin.js +0 -4
- package/lib/shared/bundler/webpack/pluginConfigs/configRuntimeResourceCleanup.js +3 -8
- package/lib/shared/bundler/webpack/pluginConfigs/configSelectorWeightPlugin.js +1 -6
- package/lib/shared/bundler/webpack/pluginConfigs/configServiceWorkerPlugin.js +3 -8
- package/lib/shared/bundler/webpack/pluginConfigs/configSourceMapPlugin.js +0 -4
- package/lib/shared/bundler/webpack/pluginConfigs/configTPHashMappingPlugin.js +1 -8
- package/lib/shared/bundler/webpack/pluginConfigs/configVariableConversionPlugin.js +1 -6
- package/lib/shared/bundler/webpack/plugins.js +3 -30
- package/lib/shared/bundler/webpack/resolvers.js +3 -17
- package/lib/shared/bundler/webpack/splitChunksConfig.js +2 -15
- package/lib/shared/bundler/webpack/statsConfig.js +2 -5
- package/lib/shared/bundler/webpack/tsLoaders.js +2 -4
- package/lib/shared/bundler/webpack/utils/index.js +1 -12
- package/lib/shared/bundler/webpack/utils/object-manipulation.js +2 -16
- package/lib/shared/bundler/webpack/utils/updateArrayWithDefault.js +0 -7
- package/lib/shared/bundler/webpack/webpackBuild.js +1 -8
- package/lib/shared/bundler/webpack/webpackConfig.js +0 -17
- package/lib/shared/commands-utils/doBasicRequirementCheck.js +0 -3
- package/lib/shared/commands-utils/getCliPath.js +5 -9
- package/lib/shared/commands-utils/index.js +0 -3
- package/lib/shared/commands-utils/log.js +0 -2
- package/lib/shared/commands-utils/readArgsFormCommandLine.js +0 -1
- package/lib/shared/commands-utils/readOptionFormCommandLine.js +0 -1
- package/lib/shared/commands-utils/spawnSyncIO.js +5 -13
- package/lib/shared/constants.js +9 -29
- package/lib/shared/fileUtils/copyFile.js +1 -8
- package/lib/shared/fileUtils/directoryIterator.js +0 -4
- package/lib/shared/fileUtils/watchRun.js +3 -24
- package/lib/shared/postcss/custom_postcss_plugins/EmptyPlugin.js +1 -6
- package/lib/shared/postcss/custom_postcss_plugins/HoverActivePlugin/constants.js +2 -3
- package/lib/shared/postcss/custom_postcss_plugins/HoverActivePlugin/handleIgnores.js +6 -13
- package/lib/shared/postcss/custom_postcss_plugins/HoverActivePlugin/index.js +6 -26
- package/lib/shared/postcss/custom_postcss_plugins/HoverActivePlugin/insertBefore.js +6 -9
- package/lib/shared/postcss/custom_postcss_plugins/HoverActivePlugin/isPreviouslyProcessed.js +0 -3
- package/lib/shared/postcss/custom_postcss_plugins/HoverActivePlugin/replaceUtils.js +2 -7
- package/lib/shared/postcss/custom_postcss_plugins/HoverActivePlugin/separateHoveredSelectorAndNormalSelector.js +0 -2
- package/lib/shared/postcss/custom_postcss_plugins/HoverActivePlugin/specialCases.js +4 -9
- package/lib/shared/postcss/custom_postcss_plugins/HoverActivePlugin/typeCheckUtils.js +0 -10
- package/lib/shared/postcss/custom_postcss_plugins/RTLSplitPlugin.js +16 -29
- package/lib/shared/postcss/custom_postcss_plugins/SelectorReplace.js +0 -17
- package/lib/shared/postcss/custom_postcss_plugins/ValueReplacer.js +4 -9
- package/lib/shared/postcss/custom_postcss_plugins/VariableModificationPlugin/index.js +27 -63
- package/lib/shared/postcss/filterPluginsAllowedForSpecficFile.js +5 -13
- package/lib/shared/postcss/getAllowedPostCssPlugins.js +0 -3
- package/lib/shared/postcss/getSpecificPostCssPlugin.js +7 -17
- package/lib/shared/postcss/runPostCssForCssFile.js +1 -9
- package/lib/shared/pre_process/runPreProcess.js +0 -11
- package/lib/shared/server/configWebpackDevMiddleware.js +1 -8
- package/lib/shared/server/corsHandling.js +2 -6
- package/lib/shared/server/getIp.js +1 -7
- package/lib/shared/server/getServerURL.js +0 -6
- package/lib/shared/server/httpsOptions.js +0 -11
- package/lib/shared/server/initExpressApp.js +1 -4
- package/lib/shared/server/initialHTMLHandling.js +7 -16
- package/lib/shared/server/mockApiHandler.js +8 -16
- package/lib/shared/server/mockServer.js +0 -7
- package/lib/shared/server/serveContextFiles.js +1 -5
- package/lib/shared/server/serverBywebpackDevMiddleware.js +4 -9
- package/lib/shared/server/startHttpServer.js +0 -3
- package/lib/shared/server/startHttpsServer.js +1 -9
- package/lib/shared/server/unwanted/addHttp2Server.js +2 -7
- package/lib/shared/server/unwanted/configWebpackDevMiddleware.js +1 -8
- package/lib/shared/server/unwanted/mockApiSupport.js +0 -2
- package/lib/shared/server/unwanted/websocketMockSetup.js +1 -7
- package/lib/shared/server/urlConcat.js +3 -8
- package/lib/shared/utils/requireLocalOrGlobal.js +10 -25
- package/lib/shared/utils/versionPrint.js +1 -6
- package/npm-shrinkwrap.json +2 -2
- package/package.json +1 -1
- package/packages/client_build_tool/test-i18n-config.js +22 -0
|
@@ -6,42 +6,33 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
6
6
|
exports.configPostCssRtl = configPostCssRtl;
|
|
7
7
|
exports.getSpecificPostCssPlugin = getSpecificPostCssPlugin;
|
|
8
8
|
exports.supportedPluginsOptionNames = void 0;
|
|
9
|
-
|
|
10
9
|
var _fs = require("fs");
|
|
11
|
-
|
|
12
10
|
var _postcssRtl = _interopRequireDefault(require("postcss-rtl"));
|
|
13
|
-
|
|
14
11
|
var _SelectorReplace = _interopRequireDefault(require("./custom_postcss_plugins/SelectorReplace"));
|
|
15
|
-
|
|
16
12
|
var _ValueReplacer = _interopRequireDefault(require("./custom_postcss_plugins/ValueReplacer"));
|
|
17
|
-
|
|
18
13
|
var _HoverActivePlugin = _interopRequireDefault(require("./custom_postcss_plugins/HoverActivePlugin"));
|
|
19
|
-
|
|
20
14
|
var _VariableModificationPlugin = _interopRequireDefault(require("./custom_postcss_plugins/VariableModificationPlugin"));
|
|
21
|
-
|
|
22
|
-
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
23
|
-
|
|
15
|
+
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
24
16
|
/* eslint-disable no-use-before-define */
|
|
17
|
+
|
|
25
18
|
function getSpecificPostCssPlugin(pluginOption) {
|
|
26
19
|
return postcssPluginMapper[pluginOption.pluginName]?.(pluginOption);
|
|
27
|
-
}
|
|
28
|
-
|
|
20
|
+
}
|
|
29
21
|
|
|
22
|
+
// eslint-disable-next-line no-unused-vars
|
|
30
23
|
function configPostCssRtl(pluginOption) {
|
|
31
24
|
return (0, _postcssRtl.default)({
|
|
32
25
|
addPrefixToSelector: function addPrefixToSelector(selector, prefix) {
|
|
33
26
|
if (prefix === '[dir]') {
|
|
34
27
|
return selector;
|
|
35
28
|
}
|
|
36
|
-
|
|
37
29
|
return `${prefix} ${selector}`; // Make selectors like [dir=rtl] > .selector
|
|
38
30
|
}
|
|
39
31
|
});
|
|
40
|
-
}
|
|
41
|
-
|
|
32
|
+
}
|
|
42
33
|
|
|
43
|
-
|
|
44
|
-
exports.supportedPluginsOptionNames =
|
|
34
|
+
// NOTE: we have keeping array because we need to maintain order (Just In Cases For Future)
|
|
35
|
+
const supportedPluginsOptionNames = exports.supportedPluginsOptionNames = ['rtl', 'valueReplacer', 'selectorReplace', 'hoverActive', 'cssVariableReplacement'];
|
|
45
36
|
const postcssPluginMapper = {
|
|
46
37
|
rtl: configPostCssRtl,
|
|
47
38
|
selectorReplace: pluginOption => (0, _SelectorReplace.default)(pluginOption),
|
|
@@ -49,7 +40,6 @@ const postcssPluginMapper = {
|
|
|
49
40
|
hoverActive: pluginOption => (0, _HoverActivePlugin.default)(pluginOption),
|
|
50
41
|
cssVariableReplacement: configCssVariableReplacement
|
|
51
42
|
};
|
|
52
|
-
|
|
53
43
|
function configCssVariableReplacement(pluginOption) {
|
|
54
44
|
const {
|
|
55
45
|
configFile
|
|
@@ -4,17 +4,11 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.runPostCssForCssFile = runPostCssForCssFile;
|
|
7
|
-
|
|
8
7
|
var _postcss = _interopRequireDefault(require("postcss"));
|
|
9
|
-
|
|
10
8
|
var _fs = require("fs");
|
|
11
|
-
|
|
12
9
|
var _getAllowedPostCssPlugins = require("./getAllowedPostCssPlugins");
|
|
13
|
-
|
|
14
10
|
var _copyFile = require("../fileUtils/copyFile");
|
|
15
|
-
|
|
16
|
-
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
17
|
-
|
|
11
|
+
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
18
12
|
function runPostCssForCssFile({
|
|
19
13
|
filename,
|
|
20
14
|
outputFile,
|
|
@@ -22,11 +16,9 @@ function runPostCssForCssFile({
|
|
|
22
16
|
}) {
|
|
23
17
|
const getAllowedPostCssPlugins = (0, _getAllowedPostCssPlugins.postcssPluginGetter)(options);
|
|
24
18
|
const allowedPostCssPlugins = getAllowedPostCssPlugins(filename);
|
|
25
|
-
|
|
26
19
|
if (allowedPostCssPlugins.length === 0) {
|
|
27
20
|
return;
|
|
28
21
|
}
|
|
29
|
-
|
|
30
22
|
const css = (0, _fs.readFileSync)(filename).toString();
|
|
31
23
|
(0, _postcss.default)(allowedPostCssPlugins).process(css, {
|
|
32
24
|
from: filename,
|
|
@@ -4,17 +4,11 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.runPreProcess = runPreProcess;
|
|
7
|
-
|
|
8
7
|
var _path = require("path");
|
|
9
|
-
|
|
10
8
|
var _fs = require("fs");
|
|
11
|
-
|
|
12
9
|
var _spawnSyncIO = require("../commands-utils/spawnSyncIO");
|
|
13
|
-
|
|
14
10
|
var _logger = require("../../logger");
|
|
15
|
-
|
|
16
11
|
var _constants = require("../constants");
|
|
17
|
-
|
|
18
12
|
function runPreProcess(options, runnerCli = 'node') {
|
|
19
13
|
const {
|
|
20
14
|
preProcess
|
|
@@ -24,19 +18,15 @@ function runPreProcess(options, runnerCli = 'node') {
|
|
|
24
18
|
runner,
|
|
25
19
|
stopNodemon
|
|
26
20
|
} = preProcess;
|
|
27
|
-
|
|
28
21
|
if (!enable || !runner) {
|
|
29
22
|
return null;
|
|
30
23
|
}
|
|
31
|
-
|
|
32
24
|
const preprocessorPath = (0, _constants.joinWithAppPath)(runner);
|
|
33
25
|
let result = null;
|
|
34
|
-
|
|
35
26
|
if ((0, _fs.existsSync)(preprocessorPath)) {
|
|
36
27
|
const preprocessorDirPath = (0, _path.dirname)(preprocessorPath);
|
|
37
28
|
const watchOptions = ['--watch', preprocessorDirPath];
|
|
38
29
|
const preprocessCli = stopNodemon ? 'node' : runnerCli;
|
|
39
|
-
|
|
40
30
|
if (preprocessCli === 'node') {
|
|
41
31
|
result = (0, _spawnSyncIO.spawnSyncIO)(preprocessCli, [preprocessorPath], {
|
|
42
32
|
stdio: 'inherit',
|
|
@@ -53,6 +43,5 @@ function runPreProcess(options, runnerCli = 'node') {
|
|
|
53
43
|
(0, _logger.errorLogger)(`preProcessor not exists ${preprocessorPath}`);
|
|
54
44
|
process.exit(0);
|
|
55
45
|
}
|
|
56
|
-
|
|
57
46
|
return result;
|
|
58
47
|
}
|
|
@@ -5,17 +5,11 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
});
|
|
6
6
|
exports.configWebpackDevMiddleware = configWebpackDevMiddleware;
|
|
7
7
|
exports.webpackDevMiddlewareConfig = webpackDevMiddlewareConfig;
|
|
8
|
-
|
|
9
8
|
var _webpack = require("webpack");
|
|
10
|
-
|
|
11
9
|
var _webpackDevMiddleware = _interopRequireDefault(require("webpack-dev-middleware"));
|
|
12
|
-
|
|
13
10
|
var _statsConfig = require("../bundler/webpack/statsConfig");
|
|
14
|
-
|
|
15
11
|
var _webpackConfig = _interopRequireDefault(require("../bundler/webpack/webpackConfig"));
|
|
16
|
-
|
|
17
|
-
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
18
|
-
|
|
12
|
+
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
19
13
|
function webpackDevMiddlewareConfig(options) {
|
|
20
14
|
const {
|
|
21
15
|
publicPath
|
|
@@ -29,7 +23,6 @@ function webpackDevMiddlewareConfig(options) {
|
|
|
29
23
|
}
|
|
30
24
|
};
|
|
31
25
|
}
|
|
32
|
-
|
|
33
26
|
function configWebpackDevMiddleware(app, options) {
|
|
34
27
|
const config = (0, _webpackConfig.default)(options);
|
|
35
28
|
const compiler = (0, _webpack.webpack)(config);
|
|
@@ -4,24 +4,20 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.corsHandling = corsHandling;
|
|
7
|
-
|
|
8
7
|
// eslint-disable-next-line no-unused-vars
|
|
9
8
|
function corsHandling(app, options) {
|
|
10
9
|
app.use((req, res, next) => {
|
|
11
10
|
// console.log('origin', req.get('origin'));
|
|
12
|
-
res.setHeader('Access-Control-Allow-Origin', req.get('origin') || '*');
|
|
13
|
-
|
|
11
|
+
res.setHeader('Access-Control-Allow-Origin', req.get('origin') || '*');
|
|
12
|
+
// res.setHeader('Access-Control-Allow-Origin', req.get('origin'));
|
|
14
13
|
res.setHeader('Access-Control-Allow-Private-Network', true);
|
|
15
14
|
res.setHeader('Access-Control-Allow-Credentials', true);
|
|
16
|
-
|
|
17
15
|
if (req.get('Access-Control-Request-Headers')) {
|
|
18
16
|
res.setHeader('Access-Control-Allow-Headers', req.get('Access-Control-Request-Headers'));
|
|
19
17
|
}
|
|
20
|
-
|
|
21
18
|
if (req.get('Access-Control-Request-Method')) {
|
|
22
19
|
res.setHeader('Access-Control-Allow-Methods', req.get('Access-Control-Request-Method'));
|
|
23
20
|
}
|
|
24
|
-
|
|
25
21
|
next();
|
|
26
22
|
});
|
|
27
23
|
app.options('/*', (req, res) => {
|
|
@@ -4,21 +4,16 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.getIp = getIp;
|
|
7
|
-
|
|
8
7
|
var _os = _interopRequireDefault(require("os"));
|
|
9
|
-
|
|
10
|
-
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
11
|
-
|
|
8
|
+
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
12
9
|
function getIp() {
|
|
13
10
|
const ifaces = _os.default.networkInterfaces();
|
|
14
|
-
|
|
15
11
|
let ips = [];
|
|
16
12
|
Object.keys(ifaces).forEach(ifname => {
|
|
17
13
|
const a = ifaces[ifname].map(iface => {
|
|
18
14
|
if (iface.family !== 'IPv4' || iface.internal !== false) {
|
|
19
15
|
return null;
|
|
20
16
|
}
|
|
21
|
-
|
|
22
17
|
return iface.address;
|
|
23
18
|
}).filter(a => a);
|
|
24
19
|
ips = ips.concat(a);
|
|
@@ -26,5 +21,4 @@ function getIp() {
|
|
|
26
21
|
ips.push('127.0.0.1');
|
|
27
22
|
return ips[0];
|
|
28
23
|
}
|
|
29
|
-
|
|
30
24
|
;
|
|
@@ -5,21 +5,17 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
});
|
|
6
6
|
exports.getServerDomain = getServerDomain;
|
|
7
7
|
exports.getServerUrl = getServerUrl;
|
|
8
|
-
|
|
9
8
|
function getServerDomain(serverInfo) {
|
|
10
9
|
const {
|
|
11
10
|
host,
|
|
12
11
|
domain,
|
|
13
12
|
k8s
|
|
14
13
|
} = serverInfo;
|
|
15
|
-
|
|
16
14
|
if (domain && !k8s) {
|
|
17
15
|
return `${host}.${domain}.zohocorpin.com`;
|
|
18
16
|
}
|
|
19
|
-
|
|
20
17
|
return host;
|
|
21
18
|
}
|
|
22
|
-
|
|
23
19
|
function getServerUrl({
|
|
24
20
|
domain,
|
|
25
21
|
k8s,
|
|
@@ -27,10 +23,8 @@ function getServerUrl({
|
|
|
27
23
|
protocol = 'http'
|
|
28
24
|
}) {
|
|
29
25
|
const prefix = protocol ? `${protocol}:` : '';
|
|
30
|
-
|
|
31
26
|
if (k8s) {
|
|
32
27
|
return `${prefix}//${domain}`;
|
|
33
28
|
}
|
|
34
|
-
|
|
35
29
|
return `${prefix}//${domain}:${port}/`;
|
|
36
30
|
}
|
|
@@ -4,43 +4,32 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.httpsOptionsWithUserFriendlyError = httpsOptionsWithUserFriendlyError;
|
|
7
|
-
|
|
8
7
|
var _logger = require("../../logger");
|
|
9
|
-
|
|
10
8
|
var _requireLocalOrGlobal = require("../utils/requireLocalOrGlobal");
|
|
11
|
-
|
|
12
9
|
const defaultCertNpm = '@zohodesk-private/client_dev_cert';
|
|
13
|
-
|
|
14
10
|
function httpsOptionsWithUserFriendlyError(options) {
|
|
15
11
|
const {
|
|
16
12
|
httpsCerts
|
|
17
13
|
} = options.server;
|
|
18
|
-
|
|
19
14
|
if (typeof httpsCerts === 'string' && httpsCerts) {
|
|
20
15
|
const certificate = (0, _requireLocalOrGlobal.requireAllPossible)(httpsCerts);
|
|
21
|
-
|
|
22
16
|
if (certificate.local) {
|
|
23
17
|
(0, _logger.verboseLogger)(`Local '${httpsCerts}' package taken as HTTPS certificate`);
|
|
24
18
|
return certificate.local.httpsOptions;
|
|
25
19
|
}
|
|
26
|
-
|
|
27
20
|
if (certificate.global) {
|
|
28
21
|
(0, _logger.messageLogger)(`Global '${httpsCerts}' package taken as HTTPS certificate`);
|
|
29
22
|
return certificate.global.httpsOptions;
|
|
30
23
|
}
|
|
31
|
-
|
|
32
24
|
(0, _logger.errorLogger)(`
|
|
33
25
|
You have given 'server.httpsCerts' as "${httpsCerts}".
|
|
34
26
|
But it seems that file path have some problem;`);
|
|
35
27
|
process.exit(0);
|
|
36
28
|
}
|
|
37
|
-
|
|
38
29
|
const globalCertificate = (0, _requireLocalOrGlobal.requireGlobal)(defaultCertNpm);
|
|
39
|
-
|
|
40
30
|
if (globalCertificate) {
|
|
41
31
|
(0, _logger.messageLogger)(`Global '${defaultCertNpm}' package taken as HTTPS certificate`);
|
|
42
32
|
return globalCertificate.httpsOptions;
|
|
43
33
|
}
|
|
44
|
-
|
|
45
34
|
return null;
|
|
46
35
|
}
|
|
@@ -4,11 +4,8 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.initExpressApp = initExpressApp;
|
|
7
|
-
|
|
8
7
|
var _express = _interopRequireDefault(require("express"));
|
|
9
|
-
|
|
10
|
-
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
11
|
-
|
|
8
|
+
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
12
9
|
function initExpressApp() {
|
|
13
10
|
const app = (0, _express.default)();
|
|
14
11
|
app.use(_express.default.json());
|
|
@@ -4,10 +4,9 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.initialHTMLHandling = initialHTMLHandling;
|
|
7
|
-
|
|
8
7
|
var _logger = require("../../logger");
|
|
9
|
-
|
|
10
8
|
/* eslint-disable no-use-before-define */
|
|
9
|
+
|
|
11
10
|
function initialHTMLHandling(compiler, app, options) {
|
|
12
11
|
const {
|
|
13
12
|
enableMockReplace
|
|
@@ -25,8 +24,9 @@ function initialHTMLHandling(compiler, app, options) {
|
|
|
25
24
|
} = options.serverExtras;
|
|
26
25
|
let initialHTML;
|
|
27
26
|
compiler.hooks.afterCompile.tap('ReactCLI', compilation => {
|
|
28
|
-
const indexHtml = compilation.assets['index.html'];
|
|
27
|
+
const indexHtml = compilation.assets['index.html'];
|
|
29
28
|
|
|
29
|
+
// compiler.outputFileSystem.readFileSync("build/index.html");
|
|
30
30
|
if (indexHtml) {
|
|
31
31
|
initialHTML = indexHtml.source();
|
|
32
32
|
}
|
|
@@ -43,53 +43,44 @@ function initialHTMLHandling(compiler, app, options) {
|
|
|
43
43
|
});
|
|
44
44
|
res.send(newHTML);
|
|
45
45
|
});
|
|
46
|
-
|
|
47
46
|
function modifyInitialHTML({
|
|
48
47
|
initialHTML,
|
|
49
48
|
enableMockReplace,
|
|
50
49
|
req
|
|
51
50
|
}) {
|
|
52
51
|
let newHTML = enableMockReplace && initialHTML ? mockReplace(initialHTML, req.query) : initialHTML;
|
|
53
|
-
|
|
54
52
|
if (req.protocol === 'http') {
|
|
55
53
|
newHTML = newHTML.replaceAll(httpsUrl, httpUrl);
|
|
56
54
|
}
|
|
57
|
-
|
|
58
55
|
return newHTML;
|
|
59
56
|
}
|
|
60
|
-
|
|
61
57
|
function mockReplace(inputHTML, query) {
|
|
62
58
|
const {
|
|
63
59
|
dir,
|
|
64
60
|
locale
|
|
65
61
|
} = query || {};
|
|
66
62
|
let newHTML = inputHTML;
|
|
67
|
-
|
|
68
63
|
if (i18nChunkSplit.chunkSplitEnable) {
|
|
69
64
|
newHTML = replaceWithRandomLocale(newHTML, i18nChunkSplit.templateLabel, locale);
|
|
70
65
|
}
|
|
71
|
-
|
|
72
66
|
if (rtlSplit.enableRTLSplit) {
|
|
73
67
|
newHTML = replaceWithRandomDir(newHTML, rtlSplit.templateLabel, dir);
|
|
74
68
|
}
|
|
75
|
-
|
|
76
69
|
return newHTML;
|
|
77
70
|
}
|
|
78
|
-
|
|
79
71
|
function replaceWithRandomLocale(initialHTML, templateLabel, queryLocale) {
|
|
80
|
-
const locales = ['ar_EG', 'da_DK', 'de_DE', 'en_US', 'es_AR', 'es_ES', 'fr_FR', 'hi_IN', 'in_ID', 'it_IT', 'iw_IL', 'ja_JP', 'nl_NL', 'pl_PL', 'pt_BR', 'pt_PT', 'ro_RO', 'ru_RU', 'sv_SE', 'ta_IN', 'te_IN', 'tr_TR', 'zh_CN', 'zh_TW'];
|
|
72
|
+
const locales = ['ar_EG', 'da_DK', 'de_DE', 'en_US', 'es_AR', 'es_ES', 'fr_FR', 'hi_IN', 'in_ID', 'it_IT', 'iw_IL', 'ja_JP', 'nl_NL', 'pl_PL', 'pt_BR', 'pt_PT', 'ro_RO', 'ru_RU', 'sv_SE', 'ta_IN', 'te_IN', 'tr_TR', 'zh_CN', 'zh_TW'];
|
|
73
|
+
// app.use(`/desk/*`, (req, res) => {
|
|
81
74
|
// const locale = 'ta_IN';
|
|
82
|
-
|
|
83
75
|
const locale = queryLocale || locales[Math.floor(Math.random() * locales.length)];
|
|
84
76
|
(0, _logger.verboseLogger)({
|
|
85
77
|
locale
|
|
86
78
|
});
|
|
87
79
|
return initialHTML.replaceAll(templateLabel, locale);
|
|
88
80
|
}
|
|
89
|
-
|
|
90
81
|
function replaceWithRandomDir(initialHTML, templateLabel, queryDir) {
|
|
91
|
-
const dirs = ['ltr', 'rtl'];
|
|
92
|
-
|
|
82
|
+
const dirs = ['ltr', 'rtl'];
|
|
83
|
+
// const dir = 'rtl';
|
|
93
84
|
const dir = queryDir || dirs[Math.floor(Math.random() * dirs.length)];
|
|
94
85
|
(0, _logger.verboseLogger)({
|
|
95
86
|
dir
|
|
@@ -5,15 +5,10 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
});
|
|
6
6
|
exports.handleMockApi = handleMockApi;
|
|
7
7
|
exports.mockApiHandler = mockApiHandler;
|
|
8
|
-
|
|
9
8
|
var _fs = require("fs");
|
|
10
|
-
|
|
11
9
|
var _httpProxyMiddleware = require("http-proxy-middleware");
|
|
12
|
-
|
|
13
10
|
var _constants = require("../constants");
|
|
14
|
-
|
|
15
11
|
var _logger = require("../../logger");
|
|
16
|
-
|
|
17
12
|
function mockApiHandler(app, options) {
|
|
18
13
|
const {
|
|
19
14
|
enable,
|
|
@@ -21,11 +16,9 @@ function mockApiHandler(app, options) {
|
|
|
21
16
|
mockEntryFile,
|
|
22
17
|
mockPrefix
|
|
23
18
|
} = options.mockServer;
|
|
24
|
-
|
|
25
19
|
if (!enable) {
|
|
26
20
|
return;
|
|
27
21
|
}
|
|
28
|
-
|
|
29
22
|
if (separateSeverPort) {
|
|
30
23
|
app.use(mockPrefix, (0, _httpProxyMiddleware.createProxyMiddleware)({
|
|
31
24
|
// eslint-disable-next-line no-useless-concat
|
|
@@ -39,29 +32,28 @@ function mockApiHandler(app, options) {
|
|
|
39
32
|
handleMockApi(mockEntryFile, app);
|
|
40
33
|
}
|
|
41
34
|
}
|
|
42
|
-
|
|
43
35
|
function handleMockApi(mockEntryFile, app) {
|
|
44
|
-
const entryFilePath = (0, _constants.joinWithAppPath)(mockEntryFile);
|
|
45
|
-
|
|
36
|
+
const entryFilePath = (0, _constants.joinWithAppPath)(mockEntryFile);
|
|
37
|
+
// eslint-disable-next-line no-use-before-define
|
|
46
38
|
const mockFunc = safeRequire(entryFilePath);
|
|
47
|
-
|
|
48
39
|
if (typeof mockFunc === 'function') {
|
|
49
40
|
// eslint-disable-next-line no-use-before-define
|
|
50
41
|
mockFunc(app);
|
|
51
42
|
return;
|
|
52
43
|
}
|
|
53
|
-
|
|
54
44
|
mockFunc?.mockApi?.(app);
|
|
55
|
-
}
|
|
56
|
-
// }
|
|
45
|
+
}
|
|
57
46
|
|
|
47
|
+
// function handleMockApi(params) {
|
|
48
|
+
|
|
49
|
+
// }
|
|
58
50
|
|
|
59
51
|
function safeRequire(entryFilePath) {
|
|
60
52
|
if (!(0, _fs.existsSync)(entryFilePath)) {
|
|
61
53
|
(0, _logger.errorLogger)(`${entryFilePath} file not exists for mockapi, Please check the file presence`);
|
|
62
54
|
return null;
|
|
63
|
-
}
|
|
64
|
-
|
|
55
|
+
}
|
|
65
56
|
|
|
57
|
+
// eslint-disable-next-line import/no-dynamic-require, global-require
|
|
66
58
|
return require(entryFilePath);
|
|
67
59
|
}
|
|
@@ -2,17 +2,11 @@
|
|
|
2
2
|
"use strict";
|
|
3
3
|
|
|
4
4
|
var _readOptions = require("../../schemas/readOptions");
|
|
5
|
-
|
|
6
5
|
var _corsHandling = require("./corsHandling");
|
|
7
|
-
|
|
8
6
|
var _getServerURL = require("./getServerURL");
|
|
9
|
-
|
|
10
7
|
var _initExpressApp = require("./initExpressApp");
|
|
11
|
-
|
|
12
8
|
var _mockApiHandler = require("./mockApiHandler");
|
|
13
|
-
|
|
14
9
|
var _startHttpServer = require("./startHttpServer");
|
|
15
|
-
|
|
16
10
|
function getMockServerExtras(options) {
|
|
17
11
|
const {
|
|
18
12
|
separateSeverPort
|
|
@@ -29,7 +23,6 @@ function getMockServerExtras(options) {
|
|
|
29
23
|
isHttps: false
|
|
30
24
|
};
|
|
31
25
|
}
|
|
32
|
-
|
|
33
26
|
const options = (0, _readOptions.getOptions)();
|
|
34
27
|
const {
|
|
35
28
|
mockEntryFile
|
|
@@ -4,11 +4,8 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.serveContextFiles = serveContextFiles;
|
|
7
|
-
|
|
8
7
|
var _express = _interopRequireDefault(require("express"));
|
|
9
|
-
|
|
10
|
-
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
11
|
-
|
|
8
|
+
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
12
9
|
function serveContextFiles(app, options) {
|
|
13
10
|
const {
|
|
14
11
|
context,
|
|
@@ -18,7 +15,6 @@ function serveContextFiles(app, options) {
|
|
|
18
15
|
contextURL
|
|
19
16
|
} = options.serverExtras;
|
|
20
17
|
app.use(`${contextURL}/fonts`, _express.default.static(`${context}/fonts`));
|
|
21
|
-
|
|
22
18
|
if (contextURL) {
|
|
23
19
|
app.use(contextURL, _express.default.static(contextFolderPath));
|
|
24
20
|
} else {
|
|
@@ -4,31 +4,26 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.run = run;
|
|
7
|
-
|
|
8
7
|
var _corsHandling = require("./corsHandling");
|
|
9
|
-
|
|
10
8
|
var _initExpressApp = require("./initExpressApp");
|
|
11
|
-
|
|
12
9
|
var _configWebpackDevMiddleware = require("./configWebpackDevMiddleware");
|
|
13
|
-
|
|
14
10
|
var _startHttpsServer = require("./startHttpsServer");
|
|
15
|
-
|
|
16
11
|
var _initialHTMLHandling = require("./initialHTMLHandling");
|
|
17
|
-
|
|
18
12
|
var _startHttpServer = require("./startHttpServer");
|
|
19
|
-
|
|
20
13
|
var _mockApiHandler = require("./mockApiHandler");
|
|
21
|
-
|
|
22
14
|
// import { serveContextFiles } from './serveContextFiles';
|
|
15
|
+
|
|
23
16
|
// import { startHttpServer } from './startHttpServer';
|
|
17
|
+
|
|
24
18
|
function run(options) {
|
|
25
19
|
const app = (0, _initExpressApp.initExpressApp)();
|
|
26
20
|
(0, _corsHandling.corsHandling)(app, options);
|
|
27
21
|
(0, _mockApiHandler.mockApiHandler)(app, options);
|
|
28
22
|
const {
|
|
29
23
|
compiler
|
|
30
|
-
} = (0, _configWebpackDevMiddleware.configWebpackDevMiddleware)(app, options);
|
|
24
|
+
} = (0, _configWebpackDevMiddleware.configWebpackDevMiddleware)(app, options);
|
|
31
25
|
|
|
26
|
+
// serveContextFiles(app, options);
|
|
32
27
|
(0, _startHttpsServer.startHttpsServer)(app, options);
|
|
33
28
|
(0, _startHttpServer.startHttpServer)(app, options);
|
|
34
29
|
(0, _initialHTMLHandling.initialHTMLHandling)(compiler, app, options);
|
|
@@ -4,9 +4,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.startHttpServer = startHttpServer;
|
|
7
|
-
|
|
8
7
|
var _logger = require("../../logger");
|
|
9
|
-
|
|
10
8
|
function startHttpServer(app, options) {
|
|
11
9
|
const {
|
|
12
10
|
serverExtras
|
|
@@ -19,7 +17,6 @@ function startHttpServer(app, options) {
|
|
|
19
17
|
if (err) {
|
|
20
18
|
throw err;
|
|
21
19
|
}
|
|
22
|
-
|
|
23
20
|
(0, _logger.messageLogger)(`Listening at ${httpUrl}`);
|
|
24
21
|
});
|
|
25
22
|
return app;
|
|
@@ -4,13 +4,9 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.startHttpsServer = startHttpsServer;
|
|
7
|
-
|
|
8
7
|
var _https = _interopRequireDefault(require("https"));
|
|
9
|
-
|
|
10
8
|
var _logger = require("../../logger");
|
|
11
|
-
|
|
12
|
-
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
13
|
-
|
|
9
|
+
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
14
10
|
function startHttpsServer(app, options) {
|
|
15
11
|
const {
|
|
16
12
|
httpsOptions,
|
|
@@ -20,18 +16,14 @@ function startHttpsServer(app, options) {
|
|
|
20
16
|
httpsPort,
|
|
21
17
|
httpsUrl
|
|
22
18
|
} = serverExtras;
|
|
23
|
-
|
|
24
19
|
if (!httpsOptions) {
|
|
25
20
|
return null;
|
|
26
21
|
}
|
|
27
|
-
|
|
28
22
|
const httpsServer = _https.default.createServer(httpsOptions, app);
|
|
29
|
-
|
|
30
23
|
httpsServer.listen(httpsPort, err => {
|
|
31
24
|
if (err) {
|
|
32
25
|
throw err;
|
|
33
26
|
}
|
|
34
|
-
|
|
35
27
|
(0, _logger.messageLogger)(`Listening at ${httpsUrl}`);
|
|
36
28
|
});
|
|
37
29
|
return httpsServer;
|
|
@@ -4,19 +4,15 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.addHttp2Server = addHttp2Server;
|
|
7
|
-
|
|
8
7
|
var _utils = require("../../../src/utils");
|
|
9
|
-
|
|
10
8
|
var _httpsOptions = require("../../../src/servers/httpsOptions");
|
|
11
|
-
|
|
12
9
|
function addHttp2Server(http2Port, host, domain, contextURL) {
|
|
13
10
|
const isCompatableHttp2 = Number(process.version.slice(1).split('.')[0]) >= 8;
|
|
14
|
-
|
|
15
11
|
if (isCompatableHttp2) {
|
|
16
12
|
const http2 = require('http2');
|
|
13
|
+
const http2Server = http2.createSecureServer(_httpsOptions.httpsOptions);
|
|
17
14
|
|
|
18
|
-
|
|
19
|
-
|
|
15
|
+
// eslint-disable-next-line no-unused-vars
|
|
20
16
|
http2Server.on('stream', (stream, headers) => {
|
|
21
17
|
stream.respond({
|
|
22
18
|
'content-type': 'text/html',
|
|
@@ -28,7 +24,6 @@ function addHttp2Server(http2Port, host, domain, contextURL) {
|
|
|
28
24
|
if (err) {
|
|
29
25
|
throw err;
|
|
30
26
|
}
|
|
31
|
-
|
|
32
27
|
(0, _utils.log)(`Listening at ${(0, _utils.getServerURL)({
|
|
33
28
|
host,
|
|
34
29
|
domain,
|
|
@@ -4,11 +4,8 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.configWebpackDevMiddleware = configWebpackDevMiddleware;
|
|
7
|
-
|
|
8
7
|
var _webpackDevMiddleware = _interopRequireDefault(require("webpack-dev-middleware"));
|
|
9
|
-
|
|
10
|
-
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
11
|
-
|
|
8
|
+
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
12
9
|
function configWebpackDevMiddleware({
|
|
13
10
|
publicPath,
|
|
14
11
|
writeToDisk,
|
|
@@ -25,20 +22,16 @@ function configWebpackDevMiddleware({
|
|
|
25
22
|
},
|
|
26
23
|
compress
|
|
27
24
|
};
|
|
28
|
-
|
|
29
25
|
if (enableDevCache) {
|
|
30
26
|
webpackServerOptions.headers['Cache-Control'] = 'public, max-age=604800';
|
|
31
27
|
}
|
|
32
|
-
|
|
33
28
|
if (disableWatch) {
|
|
34
29
|
webpackServerOptions.watchOptions = {
|
|
35
30
|
ignored: /./
|
|
36
31
|
};
|
|
37
32
|
}
|
|
38
|
-
|
|
39
33
|
if (writeToDisk) {
|
|
40
34
|
webpackServerOptions.writeToDisk = true;
|
|
41
35
|
}
|
|
42
|
-
|
|
43
36
|
return (0, _webpackDevMiddleware.default)(compiler, webpackServerOptions);
|
|
44
37
|
}
|