@zohodesk/client_build_tool 0.0.6-exp.3 → 0.0.6-exp.31
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/lib/schemas/defaultConfigValues.js +7 -1
- package/lib/shared/babel/babelWebConfig.js +4 -1
- package/lib/shared/babel/runBabelForTsFile.js +1 -1
- package/lib/shared/bundler/webpack/common/nameTemplates.js +10 -6
- package/lib/shared/bundler/webpack/custom_plugins/{CdnChangePlugin.js → CdnChangePlugin/index.js} +25 -5
- package/lib/shared/bundler/webpack/custom_plugins/CdnChangePlugin/webpackCustomJsUrlLoader.js +46 -0
- package/lib/shared/bundler/webpack/custom_plugins/I18nSplitPlugin/getI18nLoadingRuntimeModule.js +1 -1
- package/lib/shared/bundler/webpack/custom_plugins/InitialHtmlPlugin.js +4 -0
- package/lib/shared/bundler/webpack/custom_plugins/ResourceHintsPlugin.js +1 -0
- package/lib/shared/bundler/webpack/custom_plugins/SourceMapPlugin/index.js +16 -1
- package/lib/shared/bundler/webpack/custom_plugins/TPHashMappingPlugin/index.js +1 -1
- package/lib/shared/bundler/webpack/devtoolConfig.js +4 -1
- package/lib/shared/bundler/webpack/optimizationConfig.js +14 -1
- package/lib/shared/bundler/webpack/pluginConfigs/configCSSMinifierPlugin.js +5 -1
- package/lib/shared/bundler/webpack/pluginConfigs/configMiniCSSExtractPlugin.js +2 -1
- package/lib/shared/bundler/webpack/resolvers.js +2 -1
- package/lib/shared/bundler/webpack/tsLoaders.js +7 -13
- package/lib/shared/fileUtils/watchRun.js +1 -1
- package/npm-shrinkwrap.json +412 -7328
- package/package.json +1 -1
|
@@ -291,6 +291,7 @@ var _default = {
|
|
|
291
291
|
allowPrefetchingMultipleChunks: false
|
|
292
292
|
},
|
|
293
293
|
devModeContentHashAllowedTypes: null,
|
|
294
|
+
nameTemplateCustomization: null,
|
|
294
295
|
devLikeHash: {
|
|
295
296
|
value: false,
|
|
296
297
|
cli: 'dev_like_hash'
|
|
@@ -323,11 +324,16 @@ var _default = {
|
|
|
323
324
|
cssAttributes: null,
|
|
324
325
|
i18nAttributes: null
|
|
325
326
|
},
|
|
327
|
+
externals: null,
|
|
326
328
|
typeScript: {
|
|
327
329
|
enable: {
|
|
328
330
|
value: false,
|
|
329
|
-
cli: '
|
|
331
|
+
cli: 'type_script_enable'
|
|
330
332
|
}
|
|
333
|
+
},
|
|
334
|
+
optimization: {
|
|
335
|
+
jsExcludePath: '',
|
|
336
|
+
cssExcludePath: ''
|
|
331
337
|
}
|
|
332
338
|
};
|
|
333
339
|
exports.default = _default;
|
|
@@ -25,8 +25,11 @@ function babelWebConfig(options, mode) {
|
|
|
25
25
|
plugins: babelPlugins,
|
|
26
26
|
browserList
|
|
27
27
|
} = options.babelCustomizations;
|
|
28
|
+
const {
|
|
29
|
+
enable: typeScriptEnable
|
|
30
|
+
} = options.typeScript;
|
|
28
31
|
return {
|
|
29
|
-
presets: [getBabelPresetEnvConfig(browserList, mode), require.resolve('@babel/preset-react'), require.resolve('@babel/preset-typescript')],
|
|
32
|
+
presets: typeScriptEnable ? [getBabelPresetEnvConfig(browserList, mode), require.resolve('@babel/preset-react'), require.resolve('@babel/preset-typescript')] : [getBabelPresetEnvConfig(browserList, mode), require.resolve('@babel/preset-react')],
|
|
30
33
|
plugins: customBabelPlugins(babelPlugins).concat((0, _getBabelPlugin.getBabelPlugin)(options)).filter(Boolean)
|
|
31
34
|
};
|
|
32
35
|
}
|
|
@@ -25,6 +25,6 @@ function runBabelForTSFile({
|
|
|
25
25
|
// const jsSourceCode = readFileSync(filename).toString();
|
|
26
26
|
const babelConfig = (0, _babelWebConfig.babelWebConfig)(options, mode);
|
|
27
27
|
const result = (0, _core.transformFileSync)(filename, babelConfig);
|
|
28
|
-
(0, _copyFile.writeFile)(outputFile.replace('.
|
|
28
|
+
(0, _copyFile.writeFile)(outputFile.replace('.tsx', '.js'), result.code);
|
|
29
29
|
}
|
|
30
30
|
}
|
|
@@ -12,13 +12,13 @@ var _modeUtils = require("./modeUtils");
|
|
|
12
12
|
// NOTE: these below code can be done in js,
|
|
13
13
|
// we did copy paste in order to avoid unnecessary confusion
|
|
14
14
|
// NOTE: array[0] is dev mode file templates and array[1] is prod mode file templates
|
|
15
|
-
const
|
|
15
|
+
const defaultTemplates = {
|
|
16
16
|
html: ['index.html', 'index.[contenthash].html'],
|
|
17
17
|
js: ['js/[name].js', 'js/[name].[contenthash].js'],
|
|
18
|
-
chunkjs: ['js-
|
|
19
|
-
i18njs: ['i18n-
|
|
20
|
-
i18nchunkjs: ['i18n-
|
|
21
|
-
'i18n-
|
|
18
|
+
chunkjs: ['js-chunk/[name].js', 'js-chunks/[name].[contenthash].js'],
|
|
19
|
+
i18njs: ['i18n-chunk/[locale]/[name].i18n.js', 'i18n-chunk/[locale]/[name].[chunkhash].i18n.js'],
|
|
20
|
+
i18nchunkjs: ['i18n-chunk/[locale]/[name].i18n.js', // 'i18n-chunk/[locale]/[name].[chunkhash].i18n.js'
|
|
21
|
+
'i18n-chunk/[locale]/[name].[contenthash].i18n.js'],
|
|
22
22
|
i18nmanifest: ['i18n-manifest.json', 'i18n-manifest.json'],
|
|
23
23
|
workerjs: ['js/[name].js', 'js/[name].[contenthash].js'],
|
|
24
24
|
css: ['css/[name].css', 'css/[name].[contenthash].css'],
|
|
@@ -54,12 +54,16 @@ function nameTemplates(type, options) {
|
|
|
54
54
|
const {
|
|
55
55
|
enableFileNameHashing,
|
|
56
56
|
mode,
|
|
57
|
-
devLikeHash
|
|
57
|
+
devLikeHash,
|
|
58
|
+
nameTemplateCustomization
|
|
58
59
|
} = options;
|
|
59
60
|
let {
|
|
60
61
|
devModeContentHashAllowedTypes
|
|
61
62
|
} = options;
|
|
62
63
|
devModeContentHashAllowedTypes = devModeContentHashAllowedTypes || defaultDevModeContentHashAllowedTypes;
|
|
64
|
+
const templates = { ...defaultTemplates,
|
|
65
|
+
...nameTemplateCustomization
|
|
66
|
+
};
|
|
63
67
|
const templateName = templates[type];
|
|
64
68
|
|
|
65
69
|
if (!templateName) {
|
package/lib/shared/bundler/webpack/custom_plugins/{CdnChangePlugin.js → CdnChangePlugin/index.js}
RENAMED
|
@@ -7,14 +7,20 @@ exports.default = void 0;
|
|
|
7
7
|
|
|
8
8
|
var _htmlWebpackPlugin = _interopRequireDefault(require("html-webpack-plugin"));
|
|
9
9
|
|
|
10
|
-
var
|
|
10
|
+
var _webpack = require("webpack");
|
|
11
11
|
|
|
12
|
-
var
|
|
12
|
+
var _nameTemplates = require("../../common/nameTemplates");
|
|
13
|
+
|
|
14
|
+
var _modeUtils = require("../../common/modeUtils");
|
|
15
|
+
|
|
16
|
+
var _webpackCustomJsUrlLoader = _interopRequireDefault(require("./webpackCustomJsUrlLoader"));
|
|
13
17
|
|
|
14
18
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
15
19
|
|
|
16
20
|
// import { RuntimeGlobals, RuntimeModule } from 'webpack';
|
|
21
|
+
// eslint-disable-next-line import/extensions
|
|
17
22
|
// import { Template } from 'webpack';
|
|
23
|
+
// eslint-disable-next-line import/extensions
|
|
18
24
|
const pluginName = 'CdnChangePlugin'; // const MODULE_TYPE = 'css/mini-extract';
|
|
19
25
|
// class CdnChangeRuntimePlugin extends RuntimeModule {
|
|
20
26
|
// constructor(compiler, { variableName }) {
|
|
@@ -33,7 +39,7 @@ class CdnChangePlugin {
|
|
|
33
39
|
constructor(options) {
|
|
34
40
|
this.createSeparateSMap = options.createSeparateSMap;
|
|
35
41
|
this.i18nTemplate = options.i18nTemplate || '{{__I18N_CDN__}}';
|
|
36
|
-
this.variableName = options.variableName || '
|
|
42
|
+
this.variableName = options.variableName || 'window.__SMAP_PATH__';
|
|
37
43
|
this.cssTemplate = options.cssTemplate || '{{__CSS_CDN__}}';
|
|
38
44
|
this.jsTemplate = options.jsTemplate || '{{__JS_CDN__}}';
|
|
39
45
|
this.mode = options.mode || 'prod';
|
|
@@ -71,8 +77,12 @@ class CdnChangePlugin {
|
|
|
71
77
|
data.assets = { ...data.assets,
|
|
72
78
|
css: data.assets.css.map(css => `${this.cssTemplate}${css}`),
|
|
73
79
|
js: data.assets.js.map(js => {
|
|
74
|
-
if ((
|
|
75
|
-
|
|
80
|
+
if ((0, _modeUtils.isProductionMode)(mode) && createSeparateSMap && !(0, _nameTemplates.isI18nFile)(js)) {
|
|
81
|
+
if (js.includes('smap')) {
|
|
82
|
+
js = js.replace('smap/js/', `{{--js-smap}}js/`); //eslint-disable-line
|
|
83
|
+
} else {
|
|
84
|
+
js = js.replace('js/', `{{--js-smap}}js/`); //eslint-disable-line
|
|
85
|
+
}
|
|
76
86
|
}
|
|
77
87
|
|
|
78
88
|
return `${(0, _nameTemplates.isI18nFile)(js) ? this.i18nTemplate : this.jsTemplate}${js}`;
|
|
@@ -80,6 +90,16 @@ class CdnChangePlugin {
|
|
|
80
90
|
};
|
|
81
91
|
cb && cb(null, data);
|
|
82
92
|
});
|
|
93
|
+
|
|
94
|
+
compilation.hooks.runtimeRequirementInTree.for(_webpack.RuntimeGlobals.getChunkScriptFilename).tap(pluginName, (chunk, set) => {
|
|
95
|
+
if (typeof compilation.outputOptions.chunkFilename === 'string' && /\[(full)?hash(:\d+)?\]/.test(compilation.outputOptions.chunkFilename)) {
|
|
96
|
+
set.add(_webpack.RuntimeGlobals.getFullHash);
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
compilation.addRuntimeModule(chunk, // eslint-disable-next-line new-cap
|
|
100
|
+
new _webpackCustomJsUrlLoader.default('javascript', 'javascript', _webpack.RuntimeGlobals.getChunkScriptFilename, chunk => chunk.filenameTemplate || (chunk.canBeInitial() ? compilation.outputOptions.filename : compilation.outputOptions.chunkFilename), false, this.variableName));
|
|
101
|
+
return true;
|
|
102
|
+
});
|
|
83
103
|
});
|
|
84
104
|
}
|
|
85
105
|
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = void 0;
|
|
7
|
+
|
|
8
|
+
var _GetChunkFilenameRuntimeModule = _interopRequireDefault(require("webpack/lib/runtime/GetChunkFilenameRuntimeModule"));
|
|
9
|
+
|
|
10
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
11
|
+
|
|
12
|
+
// import { RuntimeGlobals, RuntimeModule, Template } from 'webpack';
|
|
13
|
+
// const GetChunkFilenameRuntimeModule = require('webpack/lib/runtime/GetChunkFilenameRuntimeModule');
|
|
14
|
+
// import GetChunkFilenameRuntimeModule from 'webpack/lib/runtime/GetChunkFilenameRuntimeModule';
|
|
15
|
+
// const first = set => {
|
|
16
|
+
// const entry = set.values().next();
|
|
17
|
+
// return entry.done ? undefined : entry.value;
|
|
18
|
+
// };
|
|
19
|
+
class CustomizedGetChunkFilenameRuntimeModule extends _GetChunkFilenameRuntimeModule.default {
|
|
20
|
+
/**
|
|
21
|
+
* @param {string} contentType the to use the content hash for
|
|
22
|
+
* @param {string} name kind of filename
|
|
23
|
+
* @param {string} global function name to be assigned
|
|
24
|
+
* @param {function(Chunk): string | FilenameFunction} getFilenameForChunk functor to get the filename or function
|
|
25
|
+
* @param {boolean} allChunks when false, only async chunks are included
|
|
26
|
+
*/
|
|
27
|
+
constructor(contentType, name, global, getFilenameForChunk, allChunks, variableName) {
|
|
28
|
+
super(contentType, name, global, getFilenameForChunk, allChunks);
|
|
29
|
+
this.contentType = contentType;
|
|
30
|
+
this.global = global;
|
|
31
|
+
this.getFilenameForChunk = getFilenameForChunk;
|
|
32
|
+
this.allChunks = allChunks;
|
|
33
|
+
this.dependentHash = true;
|
|
34
|
+
this.variableName = variableName;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
generate() {
|
|
38
|
+
const sourceCode = super.generate().toString();
|
|
39
|
+
const replaceCode = sourceCode.replaceAll('"js-chunks/', `${this.variableName} + "js-chunks/`);
|
|
40
|
+
return replaceCode;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
var _default = CustomizedGetChunkFilenameRuntimeModule;
|
|
46
|
+
exports.default = _default;
|
package/lib/shared/bundler/webpack/custom_plugins/I18nSplitPlugin/getI18nLoadingRuntimeModule.js
CHANGED
|
@@ -65,7 +65,7 @@ function getI18nLoadingRuntimeModule({
|
|
|
65
65
|
return _webpack.Template.asString([`${prefixFunc(i18nChunks)}`, `var createI18nScriptTag = ${runtimeTemplate.basicFunction('chunkId, fullsrc, resolve, reject', ['var scriptTag = document.createElement("script");', attributes ? _webpack.Template.asString(Object.entries(attributes).map(entry => {
|
|
66
66
|
const [key, value] = entry;
|
|
67
67
|
return `scriptTag.setAttribute(${JSON.stringify(key)}, ${JSON.stringify(value)});`;
|
|
68
|
-
})) : '', scriptType ? `scriptTag.type = ${JSON.stringify(scriptType)};` : '', `var onScriptComplete = ${runtimeTemplate.basicFunction('event', ['// avoid mem leaks.', 'scriptTag.onerror = scriptTag.onload = null;', 'if (event.type === \'load\') {', _webpack.Template.indent(['resolve();']), '} else {', _webpack.Template.indent(['var errorType = event && (event.type === \'load\' ? \'missing\' : event.type);', 'var realSrc = event && event.target && event.target.src || fullsrc;', 'var err = new Error("Loading I18N chunk " + chunkId + " failed.\\n(" + realSrc + ")");', 'err.code = "I18N_CHUNK_LOAD_FAILED";', 'err.type = errorType;', 'err.request = realSrc;', 'scriptTag.parentNode.removeChild(scriptTag)', 'reject(err);']), '}'])}`, 'scriptTag.onerror = scriptTag.onload = onScriptComplete;', 'scriptTag.src = fullsrc;', crossOriginLoading ? _webpack.Template.asString(['if (scriptTag.src.indexOf(window.location.origin + \'/\') !== 0) {', _webpack.Template.indent(`scriptTag.crossOrigin = ${JSON.stringify(crossOriginLoading)};`), '}']) : '', insertRoot && insertPlace || _webpack.Template.asString(['document.head.appendChild(scriptTag);']), 'return scriptTag;'])};`, `var findI18nScriptTag = ${runtimeTemplate.basicFunction('src, fullsrc', ['var existingScriptTags = document.getElementsByTagName("script");', 'for(var i = 0; i < existingScriptTags.length; i++) {', _webpack.Template.indent(['var tag = existingScriptTags[i];', 'var dataSrc = tag.getAttribute("data-src") || tag.getAttribute("src");', 'if((dataSrc === src || dataSrc === fullsrc)) return tag;']), '}', 'var existingStyleTags = document.getElementsByTagName("style");', 'for(var i = 0; i < existingStyleTags.length; i++) {', _webpack.Template.indent(['var tag = existingStyleTags[i];', 'var dataSrc = tag.getAttribute("data-src");', 'if(dataSrc === src || dataSrc === fullsrc) return tag;']), '}'])};`, `var loadI18nScriptTag = ${runtimeTemplate.basicFunction('chunkId', `return new Promise(${runtimeTemplate.basicFunction('resolve, reject', [`var src = ${_webpack.RuntimeGlobals.require}.miniI18nF(chunkId);`, `var fullsrc = ${_webpack.RuntimeGlobals.publicPath} + src;`, 'if(findI18nScriptTag(src, fullsrc)) return resolve();', 'createI18nScriptTag(chunkId, fullsrc, resolve, reject);'])});`)}`, '// object to store loaded I18N chunks', 'var installedI18nChunks = {', _webpack.Template.indent(
|
|
68
|
+
})) : '', '__webpack_require__.nc && scriptTag.setAttribute("nonce", __webpack_require__.nc)', scriptType ? `scriptTag.type = ${JSON.stringify(scriptType)};` : '', `var onScriptComplete = ${runtimeTemplate.basicFunction('event', ['// avoid mem leaks.', 'scriptTag.onerror = scriptTag.onload = null;', 'if (event.type === \'load\') {', _webpack.Template.indent(['resolve();']), '} else {', _webpack.Template.indent(['var errorType = event && (event.type === \'load\' ? \'missing\' : event.type);', 'var realSrc = event && event.target && event.target.src || fullsrc;', 'var err = new Error("Loading I18N chunk " + chunkId + " failed.\\n(" + realSrc + ")");', 'err.code = "I18N_CHUNK_LOAD_FAILED";', 'err.type = errorType;', 'err.request = realSrc;', 'scriptTag.parentNode.removeChild(scriptTag)', 'reject(err);']), '}'])}`, 'scriptTag.onerror = scriptTag.onload = onScriptComplete;', 'scriptTag.src = fullsrc;', crossOriginLoading ? _webpack.Template.asString(['if (scriptTag.src.indexOf(window.location.origin + \'/\') !== 0) {', _webpack.Template.indent(`scriptTag.crossOrigin = ${JSON.stringify(crossOriginLoading)};`), '}']) : '', insertRoot && insertPlace || _webpack.Template.asString(['document.head.appendChild(scriptTag);']), 'return scriptTag;'])};`, `var findI18nScriptTag = ${runtimeTemplate.basicFunction('src, fullsrc', ['var existingScriptTags = document.getElementsByTagName("script");', 'for(var i = 0; i < existingScriptTags.length; i++) {', _webpack.Template.indent(['var tag = existingScriptTags[i];', 'var dataSrc = tag.getAttribute("data-src") || tag.getAttribute("src");', 'if((dataSrc === src || dataSrc === fullsrc)) return tag;']), '}', 'var existingStyleTags = document.getElementsByTagName("style");', 'for(var i = 0; i < existingStyleTags.length; i++) {', _webpack.Template.indent(['var tag = existingStyleTags[i];', 'var dataSrc = tag.getAttribute("data-src");', 'if(dataSrc === src || dataSrc === fullsrc) return tag;']), '}'])};`, `var loadI18nScriptTag = ${runtimeTemplate.basicFunction('chunkId', `return new Promise(${runtimeTemplate.basicFunction('resolve, reject', [`var src = ${_webpack.RuntimeGlobals.require}.miniI18nF(chunkId);`, `var fullsrc = ${_webpack.RuntimeGlobals.publicPath} + src;`, 'if(findI18nScriptTag(src, fullsrc)) return resolve();', 'createI18nScriptTag(chunkId, fullsrc, resolve, reject);'])});`)}`, '// object to store loaded I18N chunks', 'var installedI18nChunks = {', _webpack.Template.indent(
|
|
69
69
|
/** @type {string[]} */
|
|
70
70
|
chunk.ids.map(id => `${JSON.stringify(id)}: 0`).join(',\n')), '};', '', `${_webpack.RuntimeGlobals.ensureChunkHandlers}.miniI18n = ${runtimeTemplate.basicFunction('chunkId, promises', [`var i18nChunks = ${JSON.stringify(chunkMap)};`, 'if(installedI18nChunks[chunkId]) promises.push(installedI18nChunks[chunkId]);', 'else if(installedI18nChunks[chunkId] !== 0 && i18nChunks[chunkId]) {', _webpack.Template.indent([`promises.push(installedI18nChunks[chunkId] = loadI18nScriptTag(chunkId).then(${runtimeTemplate.basicFunction('', 'installedI18nChunks[chunkId] = 0;')}, ${runtimeTemplate.basicFunction('e', ['delete installedI18nChunks[chunkId];', 'throw e;'])}));`]), '}'])};`, '']);
|
|
71
71
|
}
|
|
@@ -117,6 +117,7 @@ class ResourceHintsRuntimePlugin extends _webpack.RuntimeModule {
|
|
|
117
117
|
let link = document.createElement("link");
|
|
118
118
|
link.href = href;
|
|
119
119
|
link.rel = rel;
|
|
120
|
+
__webpack_require__.nc && link.setAttribute("nonce", __webpack_require__.nc)
|
|
120
121
|
if(href.endsWith(".css")) {
|
|
121
122
|
link.as="style";
|
|
122
123
|
} else if (href.endsWith(".js")) {
|
|
@@ -13,7 +13,7 @@ function checkSmapFilePattern(assetName) {
|
|
|
13
13
|
}
|
|
14
14
|
|
|
15
15
|
function skipRuntimeFiles(assetName) {
|
|
16
|
-
return !assetName.includes('
|
|
16
|
+
return !assetName.includes('[locale]');
|
|
17
17
|
}
|
|
18
18
|
|
|
19
19
|
const pluginName = 'SplitSourceMapPlugin'; // Purpose:
|
|
@@ -45,6 +45,21 @@ class SourceMapPlugin {
|
|
|
45
45
|
}
|
|
46
46
|
});
|
|
47
47
|
});
|
|
48
|
+
compilation.hooks.processAssets.tap({
|
|
49
|
+
name: pluginName,
|
|
50
|
+
stage: _webpack.Compilation.PROCESS_ASSETS_STAGE_DERIVED // additionalAssets: true
|
|
51
|
+
|
|
52
|
+
}, assets => {
|
|
53
|
+
Object.keys(assets).forEach(assetName => {
|
|
54
|
+
if (assetName.includes('runtime') && skipRuntimeFiles(assetName)) {
|
|
55
|
+
const runtimeAssetCode = assets[assetName].source();
|
|
56
|
+
const newAssetName = `smap/${assetName}`;
|
|
57
|
+
compilation.emitAsset(newAssetName, new RawSource(runtimeAssetCode));
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
;
|
|
61
|
+
});
|
|
62
|
+
});
|
|
48
63
|
});
|
|
49
64
|
}
|
|
50
65
|
|
|
@@ -29,7 +29,7 @@ class TPHashMappingPlugin {
|
|
|
29
29
|
|
|
30
30
|
getFiles() {
|
|
31
31
|
const hashMapping = {};
|
|
32
|
-
this.fileMappings.
|
|
32
|
+
this.fileMappings.forEach(fileInfo => {
|
|
33
33
|
const filePath = _path.default.join(this.tpFolder, fileInfo.filePath);
|
|
34
34
|
|
|
35
35
|
if (_fs.default.existsSync(filePath)) {
|
|
@@ -5,6 +5,9 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
});
|
|
6
6
|
exports.devtoolConfig = devtoolConfig;
|
|
7
7
|
|
|
8
|
+
// eslint-disable-next-line consistent-return
|
|
8
9
|
function devtoolConfig(options) {
|
|
9
|
-
|
|
10
|
+
if (options.createSeparateSMap) {
|
|
11
|
+
return options.devtool;
|
|
12
|
+
}
|
|
10
13
|
}
|
|
@@ -5,6 +5,8 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
});
|
|
6
6
|
exports.optimizationConfig = optimizationConfig;
|
|
7
7
|
|
|
8
|
+
var _terserWebpackPlugin = _interopRequireDefault(require("terser-webpack-plugin"));
|
|
9
|
+
|
|
8
10
|
var _nameTemplates = require("./common/nameTemplates");
|
|
9
11
|
|
|
10
12
|
var _hashUtils = require("./custom_plugins/I18nSplitPlugin/utils/hashUtils");
|
|
@@ -13,6 +15,8 @@ var _configCSSMinifierPlugin = require("./pluginConfigs/configCSSMinifierPlugin"
|
|
|
13
15
|
|
|
14
16
|
var _splitChunksConfig = require("./splitChunksConfig");
|
|
15
17
|
|
|
18
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
19
|
+
|
|
16
20
|
function optimizationConfig(options) {
|
|
17
21
|
const {
|
|
18
22
|
changeRuntimeChunkChar
|
|
@@ -31,10 +35,19 @@ function optimizationConfig(options) {
|
|
|
31
35
|
const suffix = // chunkSplitEnable ? '_[locale]' : '';
|
|
32
36
|
chunkSplitEnable && chunkFilenameHasContentHash ? '_[locale]' : '';
|
|
33
37
|
const char = changeRuntimeChunkChar;
|
|
38
|
+
const excludeList = options.optimization.jsExcludePath;
|
|
34
39
|
return {
|
|
35
40
|
splitChunks: (0, _splitChunksConfig.splitChunksConfig)(options),
|
|
36
41
|
minimizer: [// For webpack@5 you can use the `...` syntax to extend existing minimizers (i.e. `terser-webpack-plugin`), uncomment the next line
|
|
37
|
-
'...',
|
|
42
|
+
// '...',
|
|
43
|
+
excludeList !== '' ? new _terserWebpackPlugin.default({
|
|
44
|
+
exclude: excludeList,
|
|
45
|
+
extractComments: false // Do not extract comments to .LICENSE.txt files
|
|
46
|
+
|
|
47
|
+
}) : new _terserWebpackPlugin.default({
|
|
48
|
+
extractComments: false // Do not extract comments to .LICENSE.txt files
|
|
49
|
+
|
|
50
|
+
}), (0, _configCSSMinifierPlugin.configCSSMinifierPlugin)(options)].filter(Boolean),
|
|
38
51
|
moduleIds: 'named',
|
|
39
52
|
runtimeChunk: {
|
|
40
53
|
name: entrypoint => `runtime${char}${entrypoint.name}${suffix}`
|
|
@@ -14,11 +14,15 @@ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { de
|
|
|
14
14
|
// import UglifyCSSPlugin from '../custom_plugins/UglifyCSSPlugin';
|
|
15
15
|
// eslint-disable-next-line no-unused-vars
|
|
16
16
|
function configCSSMinifierPlugin(options) {
|
|
17
|
+
const excludeList = options.optimization.cssExcludePath;
|
|
18
|
+
|
|
17
19
|
if ((0, _modeUtils.isNotProduction)(options)) {
|
|
18
20
|
return null;
|
|
19
21
|
} // return null;
|
|
20
22
|
// return new UglifyCSSPlugin();
|
|
21
23
|
|
|
22
24
|
|
|
23
|
-
return new _cssMinimizerWebpackPlugin.default(
|
|
25
|
+
return excludeList !== '' ? new _cssMinimizerWebpackPlugin.default({
|
|
26
|
+
exclude: excludeList
|
|
27
|
+
}) : new _cssMinimizerWebpackPlugin.default();
|
|
24
28
|
}
|
|
@@ -15,7 +15,8 @@ function configMiniCSSExtractPlugin(options) {
|
|
|
15
15
|
const {
|
|
16
16
|
enableRTLSplit
|
|
17
17
|
} = options.css.plugins.rtlSplit;
|
|
18
|
-
const cssLTRFileNameTempalte = enableRTLSplit ? (0, _nameTemplates.nameTemplates)('cssdir', options) : (0, _nameTemplates.nameTemplates)('css', options);
|
|
18
|
+
const cssLTRFileNameTempalte = enableRTLSplit ? (0, _nameTemplates.nameTemplates)('cssdir', options) : (0, _nameTemplates.nameTemplates)('css', options); // eslint-disable-next-line no-undef
|
|
19
|
+
|
|
19
20
|
return new _miniCssExtractPlugin.default({
|
|
20
21
|
filename: cssLTRFileNameTempalte,
|
|
21
22
|
chunkFilename: cssLTRFileNameTempalte
|
|
@@ -62,7 +62,8 @@ function moduleResolver(options) {
|
|
|
62
62
|
modules: useAppNodeModulesAsPreferred(preferLocalFirst, [nodeModulesPath, _constants.cliNodeModulesPath].filter(Boolean)),
|
|
63
63
|
alias: { ...(defaultAlias ? _libAlias.libAlias : {}),
|
|
64
64
|
...(alias || {})
|
|
65
|
-
}
|
|
65
|
+
},
|
|
66
|
+
extensions: ['.ts', '.js', '.json', '.tsx']
|
|
66
67
|
};
|
|
67
68
|
}
|
|
68
69
|
|
|
@@ -5,19 +5,13 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
});
|
|
6
6
|
exports.tsLoaders = tsLoaders;
|
|
7
7
|
|
|
8
|
-
|
|
9
|
-
const {
|
|
10
|
-
enable
|
|
11
|
-
} = options.typeScript;
|
|
12
|
-
|
|
13
|
-
if (enable) {
|
|
14
|
-
return [{
|
|
15
|
-
test: /\.js$/,
|
|
16
|
-
exclude: /node_modules/,
|
|
17
|
-
use: 'ts-loader' // include: path.join(appPath, folder)
|
|
8
|
+
var _babelLoaderConfig = require("./loaderConfigs/babelLoaderConfig");
|
|
18
9
|
|
|
19
|
-
|
|
20
|
-
|
|
10
|
+
function tsLoaders(options) {
|
|
11
|
+
return [{
|
|
12
|
+
test: /\.tsx$/,
|
|
13
|
+
exclude: /node_modules/,
|
|
14
|
+
use: [(0, _babelLoaderConfig.babelLoaderConfig)(options)] // include: path.join(appPath, folder)
|
|
21
15
|
|
|
22
|
-
|
|
16
|
+
}];
|
|
23
17
|
}
|
|
@@ -25,7 +25,7 @@ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { de
|
|
|
25
25
|
|
|
26
26
|
const isJs = ext => ext === '.js';
|
|
27
27
|
|
|
28
|
-
const isTs = ext => ext === '.ts';
|
|
28
|
+
const isTs = ext => ext === '.ts' || ext === '.tsx';
|
|
29
29
|
|
|
30
30
|
const isCss = ext => ext === '.css';
|
|
31
31
|
|