@zohodesk/client_build_tool 0.0.13-exp.2 → 0.0.13-exp.4
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.
|
@@ -16,28 +16,13 @@ class InitialHtmlPlugin {
|
|
|
16
16
|
this.options = options;
|
|
17
17
|
}
|
|
18
18
|
|
|
19
|
-
getBaseName(str) {
|
|
20
|
-
const fileName = str.split("/").pop();
|
|
21
|
-
const parts = fileName.split("."); // Find index of the hash-like segment
|
|
22
|
-
|
|
23
|
-
const hashIndex = parts.findIndex(p => /^[0-9a-f_]{20,}$/i.test(p)); // If a hash is found, return everything before it
|
|
24
|
-
|
|
25
|
-
if (hashIndex < 0) {
|
|
26
|
-
console.error('this initial file dont have a hash');
|
|
27
|
-
return parts.slice(0, -1).join(".");
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
return parts.slice(0, hashIndex).join("."); // Otherwise fallback: remove only ".js"
|
|
31
|
-
}
|
|
32
|
-
|
|
33
19
|
apply(compiler) {
|
|
34
20
|
const {
|
|
35
21
|
filename,
|
|
36
22
|
template,
|
|
37
23
|
minify,
|
|
38
24
|
inject,
|
|
39
|
-
mainChunkName
|
|
40
|
-
enableSubResourceIntegrity
|
|
25
|
+
mainChunkName
|
|
41
26
|
} = this.options;
|
|
42
27
|
new _htmlWebpackPlugin.default({
|
|
43
28
|
filename,
|
|
@@ -52,35 +37,13 @@ class InitialHtmlPlugin {
|
|
|
52
37
|
const headTags = [];
|
|
53
38
|
const bodyTags = [];
|
|
54
39
|
data.headTags.forEach(tag => {
|
|
55
|
-
const url = tag.attributes?.src || tag.attributes?.href;
|
|
56
|
-
let chunkName;
|
|
57
|
-
|
|
58
|
-
const addIntegrity = (tag, suffix) => {
|
|
59
|
-
if (enableSubResourceIntegrity && chunkName) {
|
|
60
|
-
Object.assign(tag.attributes, {
|
|
61
|
-
integrity: `{{--${chunkName}-${suffix}-integrity}}`
|
|
62
|
-
});
|
|
63
|
-
}
|
|
64
|
-
};
|
|
65
|
-
|
|
66
|
-
if (enableSubResourceIntegrity) {
|
|
67
|
-
chunkName = this.getBaseName(url);
|
|
68
|
-
}
|
|
69
|
-
|
|
70
40
|
Object.assign(tag.attributes, {
|
|
71
41
|
nonce: '{{--CSP-nonce}}'
|
|
72
42
|
});
|
|
73
43
|
|
|
74
44
|
if (tag.tagName === 'link') {
|
|
75
|
-
addIntegrity(tag, 'link');
|
|
76
45
|
headTags.push(tag);
|
|
77
46
|
} else {
|
|
78
|
-
if (url.endsWith('.i18n.js')) {
|
|
79
|
-
addIntegrity(tag, 'i18n');
|
|
80
|
-
} else {
|
|
81
|
-
addIntegrity(tag, 'js');
|
|
82
|
-
}
|
|
83
|
-
|
|
84
47
|
bodyTags.push(tag);
|
|
85
48
|
}
|
|
86
49
|
});
|
|
@@ -16,8 +16,7 @@ var _InitialHtmlPlugin = require("../custom_plugins/InitialHtmlPlugin");
|
|
|
16
16
|
function configHtmlWebpackPlugin(options) {
|
|
17
17
|
const {
|
|
18
18
|
htmlTemplate,
|
|
19
|
-
mode
|
|
20
|
-
enableSubResourceIntegrity
|
|
19
|
+
mode
|
|
21
20
|
} = options;
|
|
22
21
|
const {
|
|
23
22
|
inject,
|
|
@@ -32,8 +31,7 @@ function configHtmlWebpackPlugin(options) {
|
|
|
32
31
|
template: appInitialHTMLTemplatePath,
|
|
33
32
|
minify: minifyHtmlOptions,
|
|
34
33
|
inject,
|
|
35
|
-
scriptLoading: 'defer'
|
|
36
|
-
enableSubResourceIntegrity
|
|
34
|
+
scriptLoading: 'defer'
|
|
37
35
|
});
|
|
38
36
|
}
|
|
39
37
|
|
|
@@ -8,10 +8,11 @@ exports.tsLoaders = tsLoaders;
|
|
|
8
8
|
var _babelLoaderConfig = require("./loaderConfigs/babelLoaderConfig");
|
|
9
9
|
|
|
10
10
|
function tsLoaders(options) {
|
|
11
|
+
console.log('testing');
|
|
11
12
|
return [{
|
|
12
|
-
test: /\.tsx
|
|
13
|
+
test: /\.tsx?$/,
|
|
13
14
|
exclude: /node_modules/,
|
|
14
|
-
use:
|
|
15
|
+
use: "ts-loader" // include: path.join(appPath, folder)
|
|
15
16
|
|
|
16
17
|
}];
|
|
17
18
|
}
|