@zohodesk/client_build_tool 0.0.11-exp.16.0 → 0.0.11-exp.17.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 +102 -0
- package/lib/allCommandsConfigs.js +7 -2
- package/lib/commands/build/commandExecutor.js +5 -1
- package/lib/commands/build/config.js +3 -2
- package/lib/commands/build/optionsProcessor.js +5 -2
- package/lib/commands/build/preProcessor.js +2 -0
- package/lib/commands/buildEs/commandExecutor.js +5 -0
- package/lib/commands/buildEs/config.js +3 -2
- package/lib/commands/buildEs/preProcessor.js +2 -0
- package/lib/commands/buildLib/commandExecutor.js +5 -0
- package/lib/commands/buildLib/config.js +3 -2
- package/lib/commands/buildLib/preProcessor.js +2 -0
- package/lib/commands/mockserver/commandExecutor.js +9 -2
- package/lib/commands/mockserver/config.js +3 -2
- package/lib/commands/pre_process/commandExecutor.js +2 -0
- package/lib/commands/pre_process/config.js +3 -2
- package/lib/commands/start/commandExecutor.js +2 -0
- package/lib/commands/start/config.js +3 -2
- package/lib/commands/start/optionsProcessor.js +4 -2
- package/lib/commands/start/preProcessor.js +2 -0
- package/lib/commands/template/commandExecutor.js +7 -0
- package/lib/commands/template/config.js +3 -2
- package/lib/commands/version/commandExecutor.js +3 -0
- package/lib/commands/version/config.js +3 -2
- package/lib/commandsRouter.js +21 -5
- package/lib/index.js +2 -0
- package/lib/logger.js +5 -0
- package/lib/schemas/applyValuesToSchema/index.js +8 -0
- package/lib/schemas/applyValuesToSchema/isObject.js +1 -0
- package/lib/schemas/applyValuesToSchema/isValid.js +2 -0
- package/lib/schemas/cliArgsToObject.js +6 -2
- package/lib/schemas/defaultConfigValues.js +17 -4
- package/lib/schemas/defaultConfigValuesOnly.js +33 -4
- package/lib/schemas/deprecatedOptionsHandler.js +16 -7
- package/lib/schemas/getNpmVersion.js +5 -0
- package/lib/schemas/giveDefaultValue.js +3 -0
- package/lib/schemas/npmConfigToObject.js +5 -2
- package/lib/schemas/readOptions.js +30 -10
- package/lib/schemas/readOptionsForConfigFile.js +12 -2
- package/lib/shared/babel/addDefaultPlugins.js +2 -0
- package/lib/shared/babel/babelWebConfig.js +10 -1
- package/lib/shared/babel/babel_plugins/removeAttributesPlugin.js +4 -0
- package/lib/shared/babel/getBabelPlugin.js +7 -2
- package/lib/shared/babel/runBabelForJSFile.js +4 -1
- package/lib/shared/babel/runBabelForTsFile.js +5 -1
- package/lib/shared/bundler/webpack/common/decidePublicPath.js +5 -0
- package/lib/shared/bundler/webpack/common/libAlias.js +3 -3
- package/lib/shared/bundler/webpack/common/modeUtils.js +5 -0
- package/lib/shared/bundler/webpack/common/nameTemplates.js +18 -11
- package/lib/shared/bundler/webpack/common/resourceBasedPublicPath.js +3 -2
- package/lib/shared/bundler/webpack/configCustomLoaders.js +1 -0
- package/lib/shared/bundler/webpack/cssLoaders.js +2 -0
- package/lib/shared/bundler/webpack/custom_plugins/BundleIntegrityReport/index.js +20 -1
- package/lib/shared/bundler/webpack/custom_plugins/CdnChangePlugin/index.js +25 -20
- package/lib/shared/bundler/webpack/custom_plugins/CdnChangePlugin/webpackCustomJsUrlLoader.js +9 -4
- package/lib/shared/bundler/webpack/custom_plugins/CustomScriptLoadingPlugin.js +23 -3
- package/lib/shared/bundler/webpack/custom_plugins/EFCTemplatePlugin.js +19 -8
- package/lib/shared/bundler/webpack/custom_plugins/I18nNumericIndexPlugin/I18nGroupRuntimeModule.js +61 -37
- package/lib/shared/bundler/webpack/custom_plugins/I18nNumericIndexPlugin/I18nNumericIndexHtmlInjectorPlugin.js +33 -15
- package/lib/shared/bundler/webpack/custom_plugins/I18nNumericIndexPlugin/I18nNumericIndexPlugin.js +108 -60
- package/lib/shared/bundler/webpack/custom_plugins/I18nNumericIndexPlugin/utils/i18nDataLoader.js +26 -20
- package/lib/shared/bundler/webpack/custom_plugins/I18nSplitPlugin/I18nFilesEmitPlugin.js +26 -5
- package/lib/shared/bundler/webpack/custom_plugins/I18nSplitPlugin/I18nKeysIdentifer.js +16 -13
- package/lib/shared/bundler/webpack/custom_plugins/I18nSplitPlugin/I18nRuntimeDealerPlugin.js +53 -19
- package/lib/shared/bundler/webpack/custom_plugins/I18nSplitPlugin/LocaleChunkAssetsStore.js +17 -2
- package/lib/shared/bundler/webpack/custom_plugins/I18nSplitPlugin/ModulesI18nKeysStore.js +13 -0
- package/lib/shared/bundler/webpack/custom_plugins/I18nSplitPlugin/constants.js +21 -11
- package/lib/shared/bundler/webpack/custom_plugins/I18nSplitPlugin/createHash.js +4 -0
- package/lib/shared/bundler/webpack/custom_plugins/I18nSplitPlugin/getI18nLoadingRuntimeModule.js +14 -4
- package/lib/shared/bundler/webpack/custom_plugins/I18nSplitPlugin/index.js +13 -3
- package/lib/shared/bundler/webpack/custom_plugins/I18nSplitPlugin/iterateModulesInChunk.js +12 -3
- package/lib/shared/bundler/webpack/custom_plugins/I18nSplitPlugin/optionsHandler.js +7 -2
- package/lib/shared/bundler/webpack/custom_plugins/I18nSplitPlugin/pathCreator.js +2 -0
- package/lib/shared/bundler/webpack/custom_plugins/I18nSplitPlugin/readI18nValues.js +3 -2
- package/lib/shared/bundler/webpack/custom_plugins/I18nSplitPlugin/templateFileName.js +4 -2
- package/lib/shared/bundler/webpack/custom_plugins/I18nSplitPlugin/templateHashHelpers.js +13 -8
- package/lib/shared/bundler/webpack/custom_plugins/I18nSplitPlugin/utils/collectI18nKeys.js +14 -2
- package/lib/shared/bundler/webpack/custom_plugins/I18nSplitPlugin/utils/getChunkModules.js +1 -0
- package/lib/shared/bundler/webpack/custom_plugins/I18nSplitPlugin/utils/hashUtils.js +3 -1
- package/lib/shared/bundler/webpack/custom_plugins/I18nSplitPlugin/utils/index.js +4 -0
- package/lib/shared/bundler/webpack/custom_plugins/I18nSplitPlugin/utils/propertiesUtils.js +25 -5
- package/lib/shared/bundler/webpack/custom_plugins/InitialHtmlPlugin.js +10 -3
- package/lib/shared/bundler/webpack/custom_plugins/ManifestJsonPlugin/addFilesNamesToManifestJson.js +6 -1
- package/lib/shared/bundler/webpack/custom_plugins/ManifestJsonPlugin/createInitialEntries.js +6 -1
- package/lib/shared/bundler/webpack/custom_plugins/ManifestJsonPlugin/createManifestJson.js +6 -0
- package/lib/shared/bundler/webpack/custom_plugins/ManifestJsonPlugin/findInitialFileNames.js +1 -0
- package/lib/shared/bundler/webpack/custom_plugins/ManifestJsonPlugin/index.js +7 -0
- package/lib/shared/bundler/webpack/custom_plugins/ManifestJsonPlugin/removeHashFromFileName.js +1 -0
- package/lib/shared/bundler/webpack/custom_plugins/ResourceHintsPlugin.js +17 -13
- package/lib/shared/bundler/webpack/custom_plugins/RtlSplitPlugin/OverwriteCssPathForRTL.js +15 -6
- package/lib/shared/bundler/webpack/custom_plugins/RtlSplitPlugin/RtlCssPlugin.js +13 -4
- package/lib/shared/bundler/webpack/custom_plugins/RtlSplitPlugin/replaceCssDirTemplate.js +6 -4
- package/lib/shared/bundler/webpack/custom_plugins/RuntimeResourceCleanup/index.js +10 -0
- package/lib/shared/bundler/webpack/custom_plugins/SelectorWeightPlugin/classHandling.js +3 -0
- package/lib/shared/bundler/webpack/custom_plugins/SelectorWeightPlugin/index.js +20 -4
- package/lib/shared/bundler/webpack/custom_plugins/SelectorWeightPlugin/selectorWeightPrefixAdder.js +12 -10
- package/lib/shared/bundler/webpack/custom_plugins/SelectorWeightPlugin/windowsModification.js +3 -2
- package/lib/shared/bundler/webpack/custom_plugins/ServiceWorkerPlugin.js +20 -7
- package/lib/shared/bundler/webpack/custom_plugins/ServiceWorkerPluginUtils.js +1 -0
- package/lib/shared/bundler/webpack/custom_plugins/SourceMapPlugin/index.js +10 -7
- package/lib/shared/bundler/webpack/custom_plugins/TPHashMappingPlugin/addHashToFilePath.js +6 -1
- package/lib/shared/bundler/webpack/custom_plugins/TPHashMappingPlugin/index.js +16 -1
- package/lib/shared/bundler/webpack/custom_plugins/UglifyCSSPlugin/index.js.js +11 -4
- package/lib/shared/bundler/webpack/custom_plugins/VariableConversionCollector/ErrorHandler.js +10 -3
- package/lib/shared/bundler/webpack/custom_plugins/VariableConversionCollector/index.js +62 -27
- package/lib/shared/bundler/webpack/custom_plugins/custom_attribute_plugin/index.js +15 -3
- package/lib/shared/bundler/webpack/custom_plugins/emitAsset.js +1 -0
- package/lib/shared/bundler/webpack/custom_plugins/getInitialAssetsFuncTemplate.js +12 -2
- package/lib/shared/bundler/webpack/custom_plugins/getInitialI18nAssetsArrayStr.js +7 -2
- package/lib/shared/bundler/webpack/defaultVendorPatternList.js +6 -2
- package/lib/shared/bundler/webpack/devtoolConfig.js +1 -0
- package/lib/shared/bundler/webpack/entryConfig.js +4 -0
- package/lib/shared/bundler/webpack/externals.js +1 -0
- package/lib/shared/bundler/webpack/getCSSLoaders.js +6 -1
- package/lib/shared/bundler/webpack/getFilenameFromModule.js +5 -1
- package/lib/shared/bundler/webpack/jsLoaders.js +10 -6
- package/lib/shared/bundler/webpack/loaderConfigs/assetLoaders.js +2 -0
- package/lib/shared/bundler/webpack/loaderConfigs/babelLoaderConfig.js +3 -2
- package/lib/shared/bundler/webpack/loaderConfigs/checkIsPatternsMatchFilename.js +12 -3
- package/lib/shared/bundler/webpack/loaderConfigs/configHtmlTemplateLoader.js +1 -0
- package/lib/shared/bundler/webpack/loaderConfigs/configPostCssLoader.js +10 -2
- package/lib/shared/bundler/webpack/loaderConfigs/configWebWorkerLoader.js +2 -0
- package/lib/shared/bundler/webpack/loaderConfigs/configsAssetsLoaders.js +12 -0
- package/lib/shared/bundler/webpack/loaderConfigs/cssClassNameGenerate.js +15 -1
- package/lib/shared/bundler/webpack/loaderConfigs/getCssLoaderOptions.js +4 -1
- package/lib/shared/bundler/webpack/loaderConfigs/i18nIdReplaceLoaderConfig.js +16 -8
- package/lib/shared/bundler/webpack/loaders/i18nIdReplaceLoader.js +29 -22
- package/lib/shared/bundler/webpack/loaders/miniCssFallBackLoader.js +2 -2
- package/lib/shared/bundler/webpack/loaders/workerLoader.js +19 -8
- package/lib/shared/bundler/webpack/optimizationConfig.js +13 -5
- package/lib/shared/bundler/webpack/outputConfig.js +9 -1
- package/lib/shared/bundler/webpack/pluginConfigs/configBundleAnalyzer.js +9 -5
- package/lib/shared/bundler/webpack/pluginConfigs/configBundleIntegrityReport.js +5 -0
- package/lib/shared/bundler/webpack/pluginConfigs/configCSSMinifierPlugin.js +9 -4
- package/lib/shared/bundler/webpack/pluginConfigs/configCdnChangePlugin.js +8 -3
- package/lib/shared/bundler/webpack/pluginConfigs/configCopyPublicFolders.js +16 -1
- package/lib/shared/bundler/webpack/pluginConfigs/configCustomAttributesPlugin.js +4 -0
- package/lib/shared/bundler/webpack/pluginConfigs/configCustomScriptLoadingStrategyPlugin.js +16 -0
- package/lib/shared/bundler/webpack/pluginConfigs/configEFCTemplatePlugin.js +5 -0
- package/lib/shared/bundler/webpack/pluginConfigs/configEnvVariables.js +5 -0
- package/lib/shared/bundler/webpack/pluginConfigs/configHtmlWebpackPlugin.js +8 -2
- package/lib/shared/bundler/webpack/pluginConfigs/configI18nIndexingPlugin.js +9 -5
- package/lib/shared/bundler/webpack/pluginConfigs/configI18nNumericHtmlInjector.js +25 -19
- package/lib/shared/bundler/webpack/pluginConfigs/configI18nNumericIndexPlugin.js +26 -12
- package/lib/shared/bundler/webpack/pluginConfigs/configI18nSplitPlugin.js +9 -3
- package/lib/shared/bundler/webpack/pluginConfigs/configIgnorePlugin.js +2 -0
- package/lib/shared/bundler/webpack/pluginConfigs/configManifestJsonPlugin.js +7 -0
- package/lib/shared/bundler/webpack/pluginConfigs/configMiniCSSExtractPlugin.js +7 -3
- package/lib/shared/bundler/webpack/pluginConfigs/configProgressPlugin.js +5 -1
- package/lib/shared/bundler/webpack/pluginConfigs/configResourceHintsPlugin.js +4 -1
- package/lib/shared/bundler/webpack/pluginConfigs/configRtlCssPlugin.js +4 -0
- package/lib/shared/bundler/webpack/pluginConfigs/configRuntimeResourceCleanup.js +8 -3
- package/lib/shared/bundler/webpack/pluginConfigs/configSelectorWeightPlugin.js +6 -1
- package/lib/shared/bundler/webpack/pluginConfigs/configServiceWorkerPlugin.js +8 -3
- package/lib/shared/bundler/webpack/pluginConfigs/configSourceMapPlugin.js +4 -0
- package/lib/shared/bundler/webpack/pluginConfigs/configTPHashMappingPlugin.js +8 -1
- package/lib/shared/bundler/webpack/pluginConfigs/configVariableConversionPlugin.js +6 -1
- package/lib/shared/bundler/webpack/plugins.js +24 -1
- package/lib/shared/bundler/webpack/resolvers.js +17 -3
- package/lib/shared/bundler/webpack/splitChunksConfig.js +15 -2
- package/lib/shared/bundler/webpack/statsConfig.js +5 -2
- package/lib/shared/bundler/webpack/tsLoaders.js +4 -2
- package/lib/shared/bundler/webpack/utils/index.js +12 -1
- package/lib/shared/bundler/webpack/utils/object-manipulation.js +16 -2
- package/lib/shared/bundler/webpack/utils/updateArrayWithDefault.js +7 -0
- package/lib/shared/bundler/webpack/webpackBuild.js +8 -1
- package/lib/shared/bundler/webpack/webpackConfig.js +17 -0
- package/lib/shared/commands-utils/doBasicRequirementCheck.js +3 -0
- package/lib/shared/commands-utils/getCliPath.js +9 -5
- package/lib/shared/commands-utils/index.js +3 -0
- package/lib/shared/commands-utils/log.js +2 -0
- package/lib/shared/commands-utils/readArgsFormCommandLine.js +1 -0
- package/lib/shared/commands-utils/readOptionFormCommandLine.js +1 -0
- package/lib/shared/commands-utils/spawnSyncIO.js +13 -5
- package/lib/shared/constants.js +29 -9
- package/lib/shared/fileUtils/copyFile.js +8 -1
- package/lib/shared/fileUtils/directoryIterator.js +4 -0
- package/lib/shared/fileUtils/watchRun.js +24 -3
- package/lib/shared/postcss/custom_postcss_plugins/EmptyPlugin.js +6 -1
- package/lib/shared/postcss/custom_postcss_plugins/HoverActivePlugin/constants.js +3 -2
- package/lib/shared/postcss/custom_postcss_plugins/HoverActivePlugin/handleIgnores.js +13 -6
- package/lib/shared/postcss/custom_postcss_plugins/HoverActivePlugin/index.js +26 -6
- package/lib/shared/postcss/custom_postcss_plugins/HoverActivePlugin/insertBefore.js +9 -6
- package/lib/shared/postcss/custom_postcss_plugins/HoverActivePlugin/isPreviouslyProcessed.js +3 -0
- package/lib/shared/postcss/custom_postcss_plugins/HoverActivePlugin/replaceUtils.js +7 -2
- package/lib/shared/postcss/custom_postcss_plugins/HoverActivePlugin/separateHoveredSelectorAndNormalSelector.js +2 -0
- package/lib/shared/postcss/custom_postcss_plugins/HoverActivePlugin/specialCases.js +9 -4
- package/lib/shared/postcss/custom_postcss_plugins/HoverActivePlugin/typeCheckUtils.js +10 -0
- package/lib/shared/postcss/custom_postcss_plugins/RTLSplitPlugin.js +29 -16
- package/lib/shared/postcss/custom_postcss_plugins/SelectorReplace.js +17 -0
- package/lib/shared/postcss/custom_postcss_plugins/ValueReplacer.js +9 -4
- package/lib/shared/postcss/custom_postcss_plugins/VariableModificationPlugin/index.js +63 -27
- package/lib/shared/postcss/filterPluginsAllowedForSpecficFile.js +13 -5
- package/lib/shared/postcss/getAllowedPostCssPlugins.js +3 -0
- package/lib/shared/postcss/getSpecificPostCssPlugin.js +17 -7
- package/lib/shared/postcss/runPostCssForCssFile.js +9 -1
- package/lib/shared/pre_process/runPreProcess.js +11 -0
- package/lib/shared/server/configWebpackDevMiddleware.js +8 -1
- package/lib/shared/server/corsHandling.js +6 -2
- package/lib/shared/server/getIp.js +7 -1
- package/lib/shared/server/getServerURL.js +6 -0
- package/lib/shared/server/httpsOptions.js +11 -0
- package/lib/shared/server/initExpressApp.js +4 -1
- package/lib/shared/server/initialHTMLHandling.js +16 -7
- package/lib/shared/server/mockApiHandler.js +16 -8
- package/lib/shared/server/mockServer.js +7 -0
- package/lib/shared/server/serveContextFiles.js +5 -1
- package/lib/shared/server/serverBywebpackDevMiddleware.js +9 -4
- package/lib/shared/server/startHttpServer.js +3 -0
- package/lib/shared/server/startHttpsServer.js +9 -1
- package/lib/shared/server/unwanted/addHttp2Server.js +7 -2
- package/lib/shared/server/unwanted/configWebpackDevMiddleware.js +8 -1
- package/lib/shared/server/unwanted/mockApiSupport.js +2 -0
- package/lib/shared/server/unwanted/websocketMockSetup.js +7 -1
- package/lib/shared/server/urlConcat.js +8 -3
- package/lib/shared/utils/requireLocalOrGlobal.js +25 -10
- package/lib/shared/utils/versionPrint.js +6 -1
- package/npm-shrinkwrap.json +2 -2
- package/package.json +1 -1
|
@@ -4,13 +4,18 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.default = void 0;
|
|
7
|
+
|
|
7
8
|
var _htmlWebpackPlugin = _interopRequireDefault(require("html-webpack-plugin"));
|
|
9
|
+
|
|
8
10
|
var _JavascriptModulesPlugin = _interopRequireDefault(require("webpack/lib/javascript/JavascriptModulesPlugin"));
|
|
11
|
+
|
|
9
12
|
var _replaceCssDirTemplate = require("./replaceCssDirTemplate");
|
|
10
|
-
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
11
|
-
// import { JavascriptModulesPlugin } from 'webpack';
|
|
12
13
|
|
|
14
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
15
|
+
|
|
16
|
+
// import { JavascriptModulesPlugin } from 'webpack';
|
|
13
17
|
const pluginName = 'OverwriteCssPathForRTL';
|
|
18
|
+
|
|
14
19
|
class OverwriteCssPathForRTL {
|
|
15
20
|
constructor(options = {
|
|
16
21
|
dirVarName: 'document.dir'
|
|
@@ -18,36 +23,40 @@ class OverwriteCssPathForRTL {
|
|
|
18
23
|
this.dirVarName = options.dirVarName || 'document.dir';
|
|
19
24
|
this.templateLabel = options.templateLabel || '{{--dir}}';
|
|
20
25
|
}
|
|
26
|
+
|
|
21
27
|
overwriteCssPathinHTML(compilation) {
|
|
22
28
|
// NOTE: need to reconsider It is not working as expected
|
|
23
29
|
_htmlWebpackPlugin.default.getHooks(compilation).beforeAssetTagGeneration.tap(pluginName, data => {
|
|
24
30
|
const {
|
|
25
31
|
assets
|
|
26
32
|
} = data;
|
|
27
|
-
return {
|
|
28
|
-
...
|
|
29
|
-
assets: {
|
|
30
|
-
...assets,
|
|
33
|
+
return { ...data,
|
|
34
|
+
assets: { ...assets,
|
|
31
35
|
css: assets.css && (0, _replaceCssDirTemplate.replaceCssDirTemplateMapper)(assets.css, this.templateLabel)
|
|
32
36
|
}
|
|
33
37
|
};
|
|
34
38
|
});
|
|
35
39
|
}
|
|
40
|
+
|
|
36
41
|
overwriteCssPathinRequireEnsure(compilation, compiler) {
|
|
37
42
|
const {
|
|
38
43
|
RawSource
|
|
39
44
|
} = compiler.webpack.sources;
|
|
45
|
+
|
|
40
46
|
_JavascriptModulesPlugin.default.getCompilationHooks(compilation).renderMain.tap(pluginName, source => {
|
|
41
47
|
const templateText = `"+(${this.dirVarName} === "rtl" ? "rtl": "ltr")+"`;
|
|
42
48
|
const replacedStr = source.source().replace(/\[dir\]/g, templateText);
|
|
43
49
|
return new RawSource(replacedStr);
|
|
44
50
|
});
|
|
45
51
|
}
|
|
52
|
+
|
|
46
53
|
apply(compiler) {
|
|
47
54
|
compiler.hooks.thisCompilation.tap(pluginName, compilation => {
|
|
48
55
|
this.overwriteCssPathinHTML(compilation);
|
|
49
56
|
this.overwriteCssPathinRequireEnsure(compilation, compiler);
|
|
50
57
|
});
|
|
51
58
|
}
|
|
59
|
+
|
|
52
60
|
}
|
|
61
|
+
|
|
53
62
|
exports.default = OverwriteCssPathForRTL;
|
|
@@ -4,15 +4,21 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.RtlCssPlugin = void 0;
|
|
7
|
+
|
|
7
8
|
var _webpack = require("webpack");
|
|
9
|
+
|
|
8
10
|
var _OverwriteCssPathForRTL = _interopRequireDefault(require("./OverwriteCssPathForRTL"));
|
|
11
|
+
|
|
9
12
|
var _RTLSplitPlugin = require("../../../../postcss/custom_postcss_plugins/RTLSplitPlugin");
|
|
13
|
+
|
|
10
14
|
var _utils = require("../../utils");
|
|
11
|
-
|
|
15
|
+
|
|
16
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
17
|
+
|
|
12
18
|
// import HtmlWebpackPlugin from 'html-webpack-plugin';
|
|
13
19
|
// import rtlcss from 'rtlcss';
|
|
14
|
-
|
|
15
20
|
const pluginName = 'RtlCssPlugin';
|
|
21
|
+
|
|
16
22
|
class RtlCssPlugin {
|
|
17
23
|
constructor(options = {}) {
|
|
18
24
|
/**
|
|
@@ -32,6 +38,7 @@ class RtlCssPlugin {
|
|
|
32
38
|
disableMinifySelector: options.disableMinifySelector
|
|
33
39
|
};
|
|
34
40
|
}
|
|
41
|
+
|
|
35
42
|
apply(compiler) {
|
|
36
43
|
const {
|
|
37
44
|
RawSource
|
|
@@ -39,12 +46,12 @@ class RtlCssPlugin {
|
|
|
39
46
|
new _OverwriteCssPathForRTL.default({
|
|
40
47
|
templateLabel: this.templateLabel,
|
|
41
48
|
dirVarName: this.dirVarName
|
|
42
|
-
}).apply(compiler);
|
|
43
|
-
// const { filename, sourcemap, config } = this.options;
|
|
49
|
+
}).apply(compiler); // const { filename, sourcemap, config } = this.options;
|
|
44
50
|
// const { devtool } = compiler.options;
|
|
45
51
|
// const postcssOptions = {
|
|
46
52
|
// map: (sourcemap === undefined && !!devtool) || !!sourcemap
|
|
47
53
|
// };
|
|
54
|
+
|
|
48
55
|
compiler.hooks.compilation.tap(pluginName, compilation => {
|
|
49
56
|
// compilation.hooks.shouldGenerateChunkAssets.tap(pluginName, (...args) => {
|
|
50
57
|
// console.log('shouldGenerateChunkAssets', args);
|
|
@@ -71,5 +78,7 @@ class RtlCssPlugin {
|
|
|
71
78
|
});
|
|
72
79
|
});
|
|
73
80
|
}
|
|
81
|
+
|
|
74
82
|
}
|
|
83
|
+
|
|
75
84
|
exports.RtlCssPlugin = RtlCssPlugin;
|
|
@@ -7,19 +7,21 @@ exports.replaceCssDirTemplate = replaceCssDirTemplate;
|
|
|
7
7
|
exports.replaceCssDirTemplateMapper = replaceCssDirTemplateMapper;
|
|
8
8
|
exports.replaceI18nLocalTemplate = replaceI18nLocalTemplate;
|
|
9
9
|
exports.replaceI18nLocaleTemplateMapper = replaceI18nLocaleTemplateMapper;
|
|
10
|
+
|
|
10
11
|
function replaceCssDirTemplate(filePath, cssDirTemplate) {
|
|
11
|
-
return filePath
|
|
12
|
-
// added for efc and service worker handling
|
|
12
|
+
return filePath // added for efc and service worker handling
|
|
13
13
|
.replaceAll('[dir]', cssDirTemplate).replace('.ltr.css', `.${cssDirTemplate}.css`);
|
|
14
14
|
}
|
|
15
|
+
|
|
15
16
|
function replaceCssDirTemplateMapper(assets, cssDirTemplate) {
|
|
16
17
|
return assets.map(filePath => replaceCssDirTemplate(filePath, cssDirTemplate));
|
|
17
18
|
}
|
|
19
|
+
|
|
18
20
|
function replaceI18nLocalTemplate(filePath, localeTemplate) {
|
|
19
|
-
return filePath
|
|
20
|
-
// added for efc and service worker handling
|
|
21
|
+
return filePath // added for efc and service worker handling
|
|
21
22
|
.replaceAll('[locale]', localeTemplate);
|
|
22
23
|
}
|
|
24
|
+
|
|
23
25
|
function replaceI18nLocaleTemplateMapper(assets, localeTemplate) {
|
|
24
26
|
return assets.map(filePath => replaceI18nLocalTemplate(filePath, localeTemplate));
|
|
25
27
|
}
|
|
@@ -4,8 +4,11 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.default = void 0;
|
|
7
|
+
|
|
7
8
|
var _webpack = require("webpack");
|
|
9
|
+
|
|
8
10
|
const pluginName = 'RuntimeResourceCleanupPlugin';
|
|
11
|
+
|
|
9
12
|
class RuntimeResourceCleanup {
|
|
10
13
|
constructor({
|
|
11
14
|
enable: scriptCleanUpEnabled,
|
|
@@ -16,6 +19,7 @@ class RuntimeResourceCleanup {
|
|
|
16
19
|
this.scriptCleanUpEnabled = scriptCleanUpEnabled;
|
|
17
20
|
this.chunkLoadingGlobal = chunkLoadingGlobal;
|
|
18
21
|
}
|
|
22
|
+
|
|
19
23
|
apply(compiler) {
|
|
20
24
|
compiler.hooks.compilation.tap(pluginName, compilation => {
|
|
21
25
|
compilation.hooks.processAssets.tap({
|
|
@@ -24,6 +28,7 @@ class RuntimeResourceCleanup {
|
|
|
24
28
|
}, assets => {
|
|
25
29
|
const runtimeFiles = Object.keys(assets).filter(assetName => /.+?runtime.*\.js$/.test(assetName));
|
|
26
30
|
const searchString = 'chunkLoadingGlobal.forEach';
|
|
31
|
+
|
|
27
32
|
function generateScriptCleanUpCode(attributes) {
|
|
28
33
|
const [[attributeKey, attributeValue]] = Object.entries(attributes);
|
|
29
34
|
const selectorForGettingResources = `[${attributeKey}="${attributeValue}"]`;
|
|
@@ -31,6 +36,7 @@ class RuntimeResourceCleanup {
|
|
|
31
36
|
document.querySelectorAll('${selectorForGettingResources}').forEach(resource => resource.remove());
|
|
32
37
|
`;
|
|
33
38
|
}
|
|
39
|
+
|
|
34
40
|
function generateRunTimeObjectCleanupCode() {
|
|
35
41
|
return `
|
|
36
42
|
Object.keys(__webpack_modules__).forEach(moduleKey => __webpack_modules__[moduleKey] = null);
|
|
@@ -41,6 +47,7 @@ class RuntimeResourceCleanup {
|
|
|
41
47
|
__webpack_require__ = null;
|
|
42
48
|
`;
|
|
43
49
|
}
|
|
50
|
+
|
|
44
51
|
function attachUninstallMethodToChunkGlobal() {
|
|
45
52
|
const {
|
|
46
53
|
chunkLoadingGlobal
|
|
@@ -50,6 +57,7 @@ class RuntimeResourceCleanup {
|
|
|
50
57
|
${this.scriptCleanUpEnabled ? generateScriptCleanUpCode(this.options.attributes) : ''}
|
|
51
58
|
}`;
|
|
52
59
|
}
|
|
60
|
+
|
|
53
61
|
runtimeFiles.forEach(runtTimeFile => {
|
|
54
62
|
const runTimeSource = assets[runtTimeFile].source();
|
|
55
63
|
const newRunTimeCode = runTimeSource.replace(searchString, `${attachUninstallMethodToChunkGlobal.call(this)};${searchString}`);
|
|
@@ -59,5 +67,7 @@ class RuntimeResourceCleanup {
|
|
|
59
67
|
});
|
|
60
68
|
});
|
|
61
69
|
}
|
|
70
|
+
|
|
62
71
|
}
|
|
72
|
+
|
|
63
73
|
exports.default = RuntimeResourceCleanup;
|
|
@@ -6,12 +6,15 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
6
6
|
exports.hasPrevNodeIgnore = hasPrevNodeIgnore;
|
|
7
7
|
exports.isAtRule = isAtRule;
|
|
8
8
|
exports.isInsideMediaQuery = isInsideMediaQuery;
|
|
9
|
+
|
|
9
10
|
function hasPrevNodeIgnore(index, prevNode, ignoreComment) {
|
|
10
11
|
return index !== 0 && prevNode && prevNode.type && prevNode.type === 'comment' && prevNode.text.toLowerCase() === ignoreComment;
|
|
11
12
|
}
|
|
13
|
+
|
|
12
14
|
function isAtRule(rule) {
|
|
13
15
|
return rule.parent && rule.parent.type === 'atrule';
|
|
14
16
|
}
|
|
17
|
+
|
|
15
18
|
function isInsideMediaQuery(rule) {
|
|
16
19
|
return !!(isAtRule(rule) && rule.parent.name === 'media');
|
|
17
20
|
}
|
|
@@ -4,11 +4,17 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.default = void 0;
|
|
7
|
+
|
|
7
8
|
var _postcss = _interopRequireDefault(require("postcss"));
|
|
9
|
+
|
|
8
10
|
var _fs = _interopRequireDefault(require("fs"));
|
|
11
|
+
|
|
9
12
|
var _selectorWeightPrefixAdder = require("./selectorWeightPrefixAdder");
|
|
13
|
+
|
|
10
14
|
var _checkIsPatternsMatchFilename = require("../../loaderConfigs/checkIsPatternsMatchFilename");
|
|
11
|
-
|
|
15
|
+
|
|
16
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
17
|
+
|
|
12
18
|
class SelectorWeightPlugin {
|
|
13
19
|
constructor(options = {}) {
|
|
14
20
|
this.options = {
|
|
@@ -19,6 +25,7 @@ class SelectorWeightPlugin {
|
|
|
19
25
|
patterns: options.patterns
|
|
20
26
|
};
|
|
21
27
|
}
|
|
28
|
+
|
|
22
29
|
apply(compiler) {
|
|
23
30
|
const {
|
|
24
31
|
defaultSelector,
|
|
@@ -26,13 +33,16 @@ class SelectorWeightPlugin {
|
|
|
26
33
|
excludeStrings,
|
|
27
34
|
patterns
|
|
28
35
|
} = this.options;
|
|
36
|
+
|
|
29
37
|
const rawdata = _fs.default.readFileSync(customFileDetails);
|
|
38
|
+
|
|
30
39
|
const data = JSON.parse(rawdata);
|
|
31
40
|
compiler.hooks.compilation.tap('selector-weight-rewrite', compilation => {
|
|
32
41
|
compilation.hooks.optimizeModules.tap('selector-weight-rewrite', modules => {
|
|
33
42
|
const mods = Array.from(modules).filter(x => x.type.includes('css'));
|
|
34
43
|
mods.forEach(module => {
|
|
35
44
|
const filename = module.issuer.resource;
|
|
45
|
+
|
|
36
46
|
if (!(0, _checkIsPatternsMatchFilename.checkIsPatternsMatchFilename)(patterns, filename)) {
|
|
37
47
|
return;
|
|
38
48
|
}
|
|
@@ -51,12 +61,18 @@ class SelectorWeightPlugin {
|
|
|
51
61
|
case filename is different ?
|
|
52
62
|
defaultSelector = '.zoho_desk_ui'
|
|
53
63
|
*/
|
|
54
|
-
|
|
55
|
-
|
|
64
|
+
|
|
65
|
+
|
|
66
|
+
const rootOriginal = _postcss.default.parse(module.content); // eslint-disable-next-line no-param-reassign
|
|
67
|
+
|
|
68
|
+
|
|
56
69
|
module.content = (0, _selectorWeightPrefixAdder.selectorWeightPrefixAdder)(rootOriginal, data[filename] ? data[filename].defaultSelector : defaultSelector, excludeStrings).toString();
|
|
57
70
|
});
|
|
58
71
|
});
|
|
59
72
|
});
|
|
60
73
|
}
|
|
74
|
+
|
|
61
75
|
}
|
|
62
|
-
|
|
76
|
+
|
|
77
|
+
var _default = SelectorWeightPlugin;
|
|
78
|
+
exports.default = _default;
|
package/lib/shared/bundler/webpack/custom_plugins/SelectorWeightPlugin/selectorWeightPrefixAdder.js
CHANGED
|
@@ -4,46 +4,48 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.selectorWeightPrefixAdder = selectorWeightPrefixAdder;
|
|
7
|
+
|
|
7
8
|
var _classHandling = require("./classHandling");
|
|
9
|
+
|
|
8
10
|
function selectorWeightPrefixAdder(rootOriginal, selector, excludeStrings) {
|
|
9
11
|
rootOriginal.walkRules((rule, index) => {
|
|
10
12
|
const prevNode = rootOriginal.nodes[index - 1];
|
|
13
|
+
|
|
11
14
|
if ((0, _classHandling.hasPrevNodeIgnore)(index, prevNode, 'updateselector:ignore')) {
|
|
12
15
|
return;
|
|
13
|
-
}
|
|
14
|
-
// TODO: need to verify cases
|
|
16
|
+
} // TODO: need to verify cases
|
|
15
17
|
// if (!isInsideMediaQuery(rule)) {
|
|
16
18
|
// return;
|
|
17
19
|
// }
|
|
20
|
+
|
|
21
|
+
|
|
18
22
|
const selectorArr = rule.selector.split(',');
|
|
19
23
|
selectorArr.forEach((singleSelectorStr, index) => {
|
|
20
24
|
if (excludeStrings.includes(singleSelectorStr.trim())) {
|
|
21
25
|
return;
|
|
22
26
|
}
|
|
27
|
+
|
|
23
28
|
if (singleSelectorStr.includes(']')) {
|
|
24
29
|
if (singleSelectorStr.slice(singleSelectorStr.lastIndexOf(']') + 2).trim() === '') {
|
|
25
30
|
return;
|
|
26
31
|
}
|
|
32
|
+
|
|
27
33
|
selectorArr[index] = `${singleSelectorStr.slice(0, singleSelectorStr.lastIndexOf(']') + 1).trim()} ${selector}${singleSelectorStr.slice(singleSelectorStr.lastIndexOf(']') + 2).trim()}`;
|
|
28
34
|
return;
|
|
29
35
|
}
|
|
36
|
+
|
|
30
37
|
selectorArr[index] = `${selector}${singleSelectorStr}`;
|
|
31
|
-
});
|
|
32
|
-
|
|
38
|
+
}); // eslint-disable-next-line no-param-reassign
|
|
39
|
+
|
|
33
40
|
rule.selector = selectorArr.join(',\n');
|
|
34
41
|
});
|
|
35
42
|
return rootOriginal;
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
// function convertSelectorWithoutAttribute (selector, conjunction) {
|
|
43
|
+
} // function convertSelectorWithoutAttribute (selector, conjunction) {
|
|
39
44
|
// const front = selector
|
|
40
45
|
// .slice(0, selector.lastIndexOf(']') + 1)
|
|
41
46
|
// .trim();
|
|
42
|
-
|
|
43
47
|
// const back = selector
|
|
44
48
|
// .slice(selector.lastIndexOf(']') + 2)
|
|
45
49
|
// .trim();
|
|
46
|
-
|
|
47
50
|
// return `${front} ${conjunction}${back}`;
|
|
48
|
-
|
|
49
51
|
// }
|
package/lib/shared/bundler/webpack/custom_plugins/SelectorWeightPlugin/windowsModification.js
CHANGED
|
@@ -6,10 +6,11 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
6
6
|
exports.windowsModification = windowsModification;
|
|
7
7
|
exports.windowsModificationFile = windowsModificationFile;
|
|
8
8
|
const isWin = process.platform === 'win32';
|
|
9
|
+
|
|
9
10
|
function windowsModification(array) {
|
|
10
11
|
return isWin ? array && Array.isArray(array) && array.map(r => r.replace(/\//g, '\\')) : array;
|
|
11
12
|
}
|
|
13
|
+
|
|
12
14
|
function windowsModificationFile(filename) {
|
|
13
15
|
return isWin ? filename.replace(/\//g, '\\') : filename;
|
|
14
|
-
}
|
|
15
|
-
// module.exports = { windowsModification, windowsModificationFile };
|
|
16
|
+
} // module.exports = { windowsModification, windowsModificationFile };
|
|
@@ -4,13 +4,21 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.default = void 0;
|
|
7
|
+
|
|
7
8
|
var _fs = require("fs");
|
|
9
|
+
|
|
8
10
|
var _LocaleChunkAssetsStore = require("./I18nSplitPlugin/LocaleChunkAssetsStore");
|
|
11
|
+
|
|
9
12
|
var _emitAsset = require("./emitAsset");
|
|
13
|
+
|
|
10
14
|
var _replaceCssDirTemplate = require("./RtlSplitPlugin/replaceCssDirTemplate");
|
|
15
|
+
|
|
11
16
|
var _getInitialAssetsFuncTemplate = require("./getInitialAssetsFuncTemplate");
|
|
17
|
+
|
|
12
18
|
var _ServiceWorkerPluginUtils = require("./ServiceWorkerPluginUtils");
|
|
19
|
+
|
|
13
20
|
const pluginName = 'ServiceWorkerPlugin';
|
|
21
|
+
|
|
14
22
|
class ServiceWorkerPlugin {
|
|
15
23
|
constructor(options) {
|
|
16
24
|
this.templateFilePath = options.templateFilePath;
|
|
@@ -20,17 +28,18 @@ class ServiceWorkerPlugin {
|
|
|
20
28
|
this.chunkSplitEnable = options.chunkSplitEnable;
|
|
21
29
|
this.enableRTLSplit = options.enableRTLSplit;
|
|
22
30
|
this.entryPointName = options.entryPointName;
|
|
23
|
-
this.replaceText = options.replaceText;
|
|
24
|
-
|
|
25
|
-
|
|
31
|
+
this.replaceText = options.replaceText; // this.publicPaths = options.publicPaths;
|
|
32
|
+
} // eslint-disable-next-line class-methods-use-this
|
|
33
|
+
|
|
26
34
|
|
|
27
|
-
// eslint-disable-next-line class-methods-use-this
|
|
28
35
|
isInitialChunk(chunk) {
|
|
29
36
|
if ('canBeInitial' in chunk) {
|
|
30
37
|
return chunk.canBeInitial();
|
|
31
38
|
}
|
|
39
|
+
|
|
32
40
|
return chunk.isInitial();
|
|
33
41
|
}
|
|
42
|
+
|
|
34
43
|
apply(compiler) {
|
|
35
44
|
compiler.hooks.thisCompilation.tap(pluginName, compilation => {
|
|
36
45
|
// Get store for cache
|
|
@@ -45,6 +54,7 @@ class ServiceWorkerPlugin {
|
|
|
45
54
|
});
|
|
46
55
|
});
|
|
47
56
|
}
|
|
57
|
+
|
|
48
58
|
createServiceWorkerFile(compilation) {
|
|
49
59
|
const {
|
|
50
60
|
templateFilePath,
|
|
@@ -66,16 +76,15 @@ class ServiceWorkerPlugin {
|
|
|
66
76
|
i18nFileNameTemplate: this.i18nFileNameTemplate,
|
|
67
77
|
functionName: 'getInitialAssets'
|
|
68
78
|
});
|
|
69
|
-
|
|
70
79
|
/**
|
|
71
80
|
* NOTE:
|
|
72
81
|
* if chunkSplitEnable is false means,
|
|
73
82
|
* serviceWorker will get i18n files path for html
|
|
74
83
|
*/
|
|
75
84
|
// chunkSplitEnable &&
|
|
85
|
+
|
|
76
86
|
[...compilation.chunks].filter(c => !this.isInitialChunk(c)).forEach(chunk => {
|
|
77
|
-
allChunkUrls = [...allChunkUrls, ...chunk.files];
|
|
78
|
-
// allI18nAssets.push(
|
|
87
|
+
allChunkUrls = [...allChunkUrls, ...chunk.files]; // allI18nAssets.push(
|
|
79
88
|
// getI18nFileUrlPathTemplate(
|
|
80
89
|
// compilation,
|
|
81
90
|
// chunk,
|
|
@@ -86,9 +95,11 @@ class ServiceWorkerPlugin {
|
|
|
86
95
|
});
|
|
87
96
|
allChunkUrls = allChunkUrls.filter(fileName => !fileName.endsWith('.map'));
|
|
88
97
|
allChunkUrls = allChunkUrls.map(fileName => fileName.replace('smap/', ''));
|
|
98
|
+
|
|
89
99
|
if (enableRTLSplit) {
|
|
90
100
|
allChunkUrls = (0, _replaceCssDirTemplate.replaceCssDirTemplateMapper)(allChunkUrls, _getInitialAssetsFuncTemplate.cssDirTemplate);
|
|
91
101
|
}
|
|
102
|
+
|
|
92
103
|
const mod = templateContent.replace(this.replaceText, `
|
|
93
104
|
${initialAssetsFuncTemplate}
|
|
94
105
|
|
|
@@ -103,5 +114,7 @@ class ServiceWorkerPlugin {
|
|
|
103
114
|
self.allChunks = ${JSON.stringify(allChunkUrls.concat(allI18nAssets))};`);
|
|
104
115
|
(0, _emitAsset.emitAsset)(compilation, outputFilePath, mod);
|
|
105
116
|
}
|
|
117
|
+
|
|
106
118
|
}
|
|
119
|
+
|
|
107
120
|
exports.default = ServiceWorkerPlugin;
|
|
@@ -4,6 +4,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.getI18nFileUrlPathTemplate = getI18nFileUrlPathTemplate;
|
|
7
|
+
|
|
7
8
|
function getI18nFileUrlPathTemplate(compilation, chunk, filenameTemplate, localeTemplate) {
|
|
8
9
|
const urlpath = compilation.getPath(filenameTemplate, {
|
|
9
10
|
chunk
|
|
@@ -4,18 +4,20 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.SourceMapPlugin = void 0;
|
|
7
|
+
|
|
7
8
|
var _webpack = require("webpack");
|
|
8
|
-
/* eslint-disable class-methods-use-this */
|
|
9
9
|
|
|
10
|
+
/* eslint-disable class-methods-use-this */
|
|
10
11
|
function checkSmapFilePattern(assetName) {
|
|
11
12
|
return /\.js$/.test(assetName) && !/\.i18n\.js$/.test(assetName) || /\.js\.map$/.test(assetName) && !/\.i18n\.js\.map$/.test(assetName);
|
|
12
13
|
}
|
|
14
|
+
|
|
13
15
|
function skipRuntimeFiles(assetName) {
|
|
14
16
|
return !assetName.includes('[locale]');
|
|
15
17
|
}
|
|
16
|
-
const pluginName = 'SplitSourceMapPlugin';
|
|
17
18
|
|
|
18
|
-
// Purpose:
|
|
19
|
+
const pluginName = 'SplitSourceMapPlugin'; // Purpose:
|
|
20
|
+
|
|
19
21
|
/**
|
|
20
22
|
* we want build that can load files source map and without sourcemap at the same time,
|
|
21
23
|
* or can be mentioned as so single build need to support two different clients that one for fast load and one for debugging.
|
|
@@ -33,16 +35,16 @@ class SourceMapPlugin {
|
|
|
33
35
|
}, assets => {
|
|
34
36
|
Object.keys(assets).forEach(assetName => {
|
|
35
37
|
const assetCode = assets[assetName].source();
|
|
38
|
+
|
|
36
39
|
if (checkSmapFilePattern(assetName) && skipRuntimeFiles(assetName)) {
|
|
37
40
|
compilation.renameAsset(assetName, `smap/${assetName}`);
|
|
41
|
+
|
|
38
42
|
if (!/\.map$/.test(assetName)) {
|
|
39
43
|
compilation.emitAsset(assetName, new RawSource(assetCode));
|
|
40
44
|
}
|
|
41
45
|
}
|
|
42
46
|
});
|
|
43
|
-
});
|
|
44
|
-
// if contenthash enabled we need to add this to include the runtime files
|
|
45
|
-
|
|
47
|
+
}); // if contenthash enabled we need to add this to include the runtime files
|
|
46
48
|
// compilation.hooks.processAssets.tap(
|
|
47
49
|
// {
|
|
48
50
|
// name: pluginName,
|
|
@@ -60,9 +62,10 @@ class SourceMapPlugin {
|
|
|
60
62
|
// );
|
|
61
63
|
// };
|
|
62
64
|
// });
|
|
63
|
-
|
|
64
65
|
// });
|
|
65
66
|
});
|
|
66
67
|
}
|
|
68
|
+
|
|
67
69
|
}
|
|
70
|
+
|
|
68
71
|
exports.SourceMapPlugin = SourceMapPlugin;
|
|
@@ -4,14 +4,19 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.addHashToFilePath = addHashToFilePath;
|
|
7
|
+
|
|
7
8
|
var _path = _interopRequireDefault(require("path"));
|
|
8
|
-
|
|
9
|
+
|
|
10
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
11
|
+
|
|
9
12
|
function addHashToFilePath(filePath, hash) {
|
|
10
13
|
const pathObj = _path.default.parse(filePath);
|
|
14
|
+
|
|
11
15
|
const updatedFilePath = _path.default.format({
|
|
12
16
|
dir: pathObj.dir,
|
|
13
17
|
name: `${pathObj.name}.${hash}`,
|
|
14
18
|
ext: pathObj.ext
|
|
15
19
|
});
|
|
20
|
+
|
|
16
21
|
return updatedFilePath;
|
|
17
22
|
}
|
|
@@ -4,31 +4,44 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.TPHashMappingPlugin = void 0;
|
|
7
|
+
|
|
7
8
|
var _webpack = require("webpack");
|
|
9
|
+
|
|
8
10
|
var _fs = _interopRequireDefault(require("fs"));
|
|
11
|
+
|
|
9
12
|
var _path = _interopRequireDefault(require("path"));
|
|
13
|
+
|
|
10
14
|
var _addHashToFilePath = require("./addHashToFilePath");
|
|
15
|
+
|
|
11
16
|
var _cssClassNameGenerate = require("../../loaderConfigs/cssClassNameGenerate");
|
|
12
|
-
|
|
17
|
+
|
|
18
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
19
|
+
|
|
13
20
|
class TPHashMappingPlugin {
|
|
14
21
|
constructor(options) {
|
|
15
22
|
this.fileMappings = options.fileMappings;
|
|
16
23
|
this.tpFolder = options.tpFolder;
|
|
17
24
|
}
|
|
25
|
+
|
|
18
26
|
apply(compiler) {
|
|
19
27
|
new _webpack.DefinePlugin(this.getFiles()).apply(compiler);
|
|
20
28
|
}
|
|
29
|
+
|
|
21
30
|
getFiles() {
|
|
22
31
|
const hashMapping = {};
|
|
23
32
|
this.fileMappings.forEach(fileInfo => {
|
|
24
33
|
const filePath = _path.default.join(this.tpFolder, fileInfo.filePath);
|
|
34
|
+
|
|
25
35
|
if (_fs.default.existsSync(filePath)) {
|
|
26
36
|
const fileContent = _fs.default.readFileSync(filePath, {
|
|
27
37
|
encoding: 'utf-8'
|
|
28
38
|
});
|
|
39
|
+
|
|
29
40
|
const generatedHash = (0, _cssClassNameGenerate.getHash)(fileContent, fileInfo.hashLength || 10);
|
|
30
41
|
const outputFilePath = (0, _addHashToFilePath.addHashToFilePath)(filePath, generatedHash);
|
|
42
|
+
|
|
31
43
|
_fs.default.writeFileSync(outputFilePath, fileContent);
|
|
44
|
+
|
|
32
45
|
hashMapping[fileInfo.key] = JSON.stringify(generatedHash);
|
|
33
46
|
} else {
|
|
34
47
|
throw new Error(`Third party file ${fileInfo.fileName} does not exist`);
|
|
@@ -36,5 +49,7 @@ class TPHashMappingPlugin {
|
|
|
36
49
|
});
|
|
37
50
|
return hashMapping;
|
|
38
51
|
}
|
|
52
|
+
|
|
39
53
|
}
|
|
54
|
+
|
|
40
55
|
exports.TPHashMappingPlugin = TPHashMappingPlugin;
|
|
@@ -4,15 +4,17 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.default = void 0;
|
|
7
|
+
|
|
7
8
|
var _uglifycss = _interopRequireDefault(require("uglifycss"));
|
|
9
|
+
|
|
8
10
|
var _webpack = require("webpack");
|
|
9
|
-
|
|
11
|
+
|
|
12
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
13
|
+
|
|
10
14
|
/* eslint-disable class-methods-use-this */
|
|
11
15
|
// import { RawSource } from 'webpack-sources';
|
|
16
|
+
const pluginName = 'UglifyCSSPlugin'; // TODO: Check for css minimizer plugin
|
|
12
17
|
|
|
13
|
-
const pluginName = 'UglifyCSSPlugin';
|
|
14
|
-
|
|
15
|
-
// TODO: Check for css minimizer plugin
|
|
16
18
|
class UglifyCSSPlugin {
|
|
17
19
|
apply(compiler) {
|
|
18
20
|
const {
|
|
@@ -26,10 +28,13 @@ class UglifyCSSPlugin {
|
|
|
26
28
|
Object.keys(assets).filter(filename => /\.css$/.test(filename)).forEach(filename => {
|
|
27
29
|
try {
|
|
28
30
|
let asset = assets[filename].source();
|
|
31
|
+
|
|
29
32
|
if (typeof asset !== 'string') {
|
|
30
33
|
asset = asset.toString();
|
|
31
34
|
}
|
|
35
|
+
|
|
32
36
|
const result = _uglifycss.default.processString(asset);
|
|
37
|
+
|
|
33
38
|
compilation.updateAsset(filename, new RawSource(result));
|
|
34
39
|
} catch (e) {
|
|
35
40
|
compilation.errors.push(e);
|
|
@@ -38,5 +43,7 @@ class UglifyCSSPlugin {
|
|
|
38
43
|
});
|
|
39
44
|
});
|
|
40
45
|
}
|
|
46
|
+
|
|
41
47
|
}
|
|
48
|
+
|
|
42
49
|
exports.default = UglifyCSSPlugin;
|
package/lib/shared/bundler/webpack/custom_plugins/VariableConversionCollector/ErrorHandler.js
CHANGED
|
@@ -4,6 +4,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.errHandler = exports.ErrorHandler = void 0;
|
|
7
|
+
|
|
7
8
|
class ErrorHandler {
|
|
8
9
|
constructor(allowedErrs) {
|
|
9
10
|
this.errors = [];
|
|
@@ -19,6 +20,7 @@ class ErrorHandler {
|
|
|
19
20
|
MULTIPLE_OCCURANCES: errObj => this.addError(` prop: ${errObj.decl.prop} ,\n value : ${errObj.decl.value} ,\n filename : ${errObj.filename} ,\n filepath : ${errObj.path} ,\n line : ${errObj.decl.source.start.line} ,\n message : ${errObj.message}`)
|
|
20
21
|
});
|
|
21
22
|
}
|
|
23
|
+
|
|
22
24
|
setAllowedErrs(allErrs) {
|
|
23
25
|
this.allowedErrs = allErrs;
|
|
24
26
|
['DECLARATION_IGNORED', 'DECIMAL_CHECK', 'DECIMAL_REJECT', 'UNIT_ERROR', 'RANGE_ERROR', 'VARIABLE_PRESENT', 'MULTIPLE_OCCURANCES'].forEach(err => {
|
|
@@ -27,16 +29,18 @@ class ErrorHandler {
|
|
|
27
29
|
}
|
|
28
30
|
});
|
|
29
31
|
}
|
|
32
|
+
|
|
30
33
|
addError(errstr) {
|
|
31
34
|
this.errors.push(`{\n${errstr}\n}\n`);
|
|
32
35
|
}
|
|
36
|
+
|
|
33
37
|
errorFunction(errObj) {
|
|
34
38
|
if (errObj.type && this.allowedErrs[errObj.type] && errObj.decl.prop && errObj.decl.value) {
|
|
35
39
|
this[errObj.type](errObj);
|
|
36
40
|
}
|
|
37
|
-
}
|
|
41
|
+
} // eslint-disable-next-line class-methods-use-this
|
|
42
|
+
|
|
38
43
|
|
|
39
|
-
// eslint-disable-next-line class-methods-use-this
|
|
40
44
|
printError(errObj) {
|
|
41
45
|
console.log('{');
|
|
42
46
|
Object.keys(errObj).sort().forEach(key => {
|
|
@@ -50,6 +54,9 @@ class ErrorHandler {
|
|
|
50
54
|
});
|
|
51
55
|
console.log('}\n');
|
|
52
56
|
}
|
|
57
|
+
|
|
53
58
|
}
|
|
59
|
+
|
|
54
60
|
exports.ErrorHandler = ErrorHandler;
|
|
55
|
-
const errHandler =
|
|
61
|
+
const errHandler = new ErrorHandler();
|
|
62
|
+
exports.errHandler = errHandler;
|