mod-build 4.0.1 → 4.0.3
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/CHANGELOG.md +4 -0
- package/package.json +2 -6
- package/src/scripts/default/rage-clicking.js +47 -0
- package/src/scripts/globals.js +2 -1
- package/src/scripts/plugins.js +49 -26
package/CHANGELOG.md
CHANGED
package/package.json
CHANGED
|
@@ -1,26 +1,22 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "mod-build",
|
|
3
|
-
"version": "4.0.
|
|
3
|
+
"version": "4.0.3",
|
|
4
4
|
"description": "Share components for S3 sites.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"scripts": {
|
|
7
7
|
"dev": "export NODE_ENV=qa.modernize.com IS_LOCAL=true && vite",
|
|
8
8
|
"build": "export NODE_ENV=modernize.com && vite build",
|
|
9
|
-
"preview": "export NODE_ENV=modernize.com && vite preview"
|
|
9
|
+
"preview": "export NODE_ENV=modernize.com && vite build && vite preview"
|
|
10
10
|
},
|
|
11
11
|
"dependencies": {
|
|
12
|
-
"@rollup/plugin-inject": "^5.0.5",
|
|
13
12
|
"@vituum/vite-plugin-handlebars": "^1.1.0",
|
|
14
13
|
"axios": "^1.6.2",
|
|
15
|
-
"del": "^7.1.0",
|
|
16
|
-
"eslint": "^8.55.0",
|
|
17
14
|
"glob": "^10.3.10",
|
|
18
15
|
"gulp": "^4.0.2",
|
|
19
16
|
"gulp-handlebars-file-include": "^1.0.0",
|
|
20
17
|
"gulp-hash": "^4.2.2",
|
|
21
18
|
"gulp-replace": "^1.1.4",
|
|
22
19
|
"gulp-tap": "^2.0.0",
|
|
23
|
-
"husky": "^8.0.3",
|
|
24
20
|
"lodash.merge": "^4.6.2",
|
|
25
21
|
"lodash.mergewith": "^4.6.2",
|
|
26
22
|
"sass": "^1.69.5",
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
export const preventRageClicks = (steps = '.step', swiperEl = '.swiper') => {
|
|
2
|
+
const $allButtons = document.querySelectorAll('button');
|
|
3
|
+
const $steps = document.querySelectorAll(steps);
|
|
4
|
+
const swiper = document.querySelector(swiperEl).swiper;
|
|
5
|
+
|
|
6
|
+
if ($allButtons && swiper && $steps) {
|
|
7
|
+
let isTransitionStart = false;
|
|
8
|
+
let clickHandler = (e) => {
|
|
9
|
+
e.preventDefault();
|
|
10
|
+
e.stopPropagation();
|
|
11
|
+
};
|
|
12
|
+
|
|
13
|
+
swiper.on('slideChange', () => {
|
|
14
|
+
isTransitionStart = true;
|
|
15
|
+
|
|
16
|
+
$allButtons.forEach((button) => {
|
|
17
|
+
button.addEventListener('click', clickHandler);
|
|
18
|
+
button.disabled = true;
|
|
19
|
+
});
|
|
20
|
+
});
|
|
21
|
+
|
|
22
|
+
swiper.on('slideChangeTransitionEnd', () => {
|
|
23
|
+
if (isTransitionStart) {
|
|
24
|
+
isTransitionStart = false;
|
|
25
|
+
|
|
26
|
+
$allButtons.forEach((button) => {
|
|
27
|
+
button.disabled = false;
|
|
28
|
+
button.removeEventListener('click', clickHandler);
|
|
29
|
+
});
|
|
30
|
+
|
|
31
|
+
$steps.forEach((step) => {
|
|
32
|
+
step.classList.remove(window.modForm.opts.stepActiveCls);
|
|
33
|
+
});
|
|
34
|
+
|
|
35
|
+
document
|
|
36
|
+
.querySelector(`${steps}.swiper-slide-active`)
|
|
37
|
+
.classList.add(window.modForm.opts.stepActiveCls);
|
|
38
|
+
|
|
39
|
+
document
|
|
40
|
+
.querySelector(`${steps}.step[aria-hidden="false"]`)
|
|
41
|
+
.focus();
|
|
42
|
+
|
|
43
|
+
swiper.update();
|
|
44
|
+
}
|
|
45
|
+
});
|
|
46
|
+
}
|
|
47
|
+
};
|
package/src/scripts/globals.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { useDynamicGtm } from './default/use-dynamic-gtm.js';
|
|
2
2
|
import { loadAdditionalAssets } from './default/additional-assets.js';
|
|
3
3
|
import { updateFooterLinkPaths } from './default/update-link-paths.js';
|
|
4
|
+
import { preventRageClicks } from './default/rage-clicking.js';
|
|
4
5
|
|
|
5
6
|
function globalFunctions(config) {
|
|
6
7
|
useDynamicGtm(config);
|
|
@@ -8,4 +9,4 @@ function globalFunctions(config) {
|
|
|
8
9
|
updateFooterLinkPaths();
|
|
9
10
|
}
|
|
10
11
|
|
|
11
|
-
export { globalFunctions };
|
|
12
|
+
export { globalFunctions, preventRageClicks };
|
package/src/scripts/plugins.js
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import fs from "node:fs";
|
|
2
|
-
import mergeWith from "lodash.mergewith";
|
|
3
2
|
import merge from "lodash.merge";
|
|
4
3
|
import gulpHandlebarsFileInclude from "gulp-handlebars-file-include";
|
|
5
4
|
import { defaultSettings } from "../data/config.js";
|
|
@@ -33,21 +32,10 @@ export const STATIC_COPY_TARGETS = [
|
|
|
33
32
|
},
|
|
34
33
|
];
|
|
35
34
|
|
|
36
|
-
|
|
37
|
-
let tempConfigExists;
|
|
38
|
-
|
|
39
|
-
const customizer = (objValue, srcValue) => {
|
|
40
|
-
// If the key exists in parsedConfig but not in mergedConfig, drop it from the merged result
|
|
41
|
-
if (srcValue === undefined) {
|
|
42
|
-
return undefined;
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
// Otherwise, use the default merging behavior
|
|
46
|
-
return merge(objValue, srcValue); // or you can return merge(objValue, srcValue) to merge nested objects
|
|
47
|
-
};
|
|
48
|
-
|
|
49
|
-
const checkForTempConfig = (config) => {
|
|
35
|
+
export const updateConfig = async (config) => {
|
|
50
36
|
const { isLocal, nodeEnv, buildPath } = defaultSettings;
|
|
37
|
+
// eslint-disable-next-line no-unused-vars
|
|
38
|
+
let tempConfigExists;
|
|
51
39
|
|
|
52
40
|
let mergedConfig = {
|
|
53
41
|
...config,
|
|
@@ -55,23 +43,23 @@ const checkForTempConfig = (config) => {
|
|
|
55
43
|
...{ isLocal, nodeEnv, buildPath }
|
|
56
44
|
};
|
|
57
45
|
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
46
|
+
const checkForTempConfig = () => {
|
|
47
|
+
return new Promise((resolve) => {
|
|
48
|
+
tempConfigExists = fs.existsSync(`src/.tmp/config.json`);
|
|
49
|
+
|
|
61
50
|
const configData = fs.readFileSync('src/.tmp/config.json', 'utf8');
|
|
62
51
|
const parsedConfig = JSON.parse(configData);
|
|
63
|
-
mergedConfig =
|
|
64
|
-
}
|
|
65
|
-
resolve(mergedConfig);
|
|
66
|
-
});
|
|
67
|
-
};
|
|
52
|
+
mergedConfig = merge(parsedConfig, mergedConfig);
|
|
68
53
|
|
|
69
|
-
|
|
70
|
-
|
|
54
|
+
resolve();
|
|
55
|
+
});
|
|
56
|
+
};
|
|
71
57
|
|
|
72
58
|
return {
|
|
73
59
|
name: 'update-config',
|
|
74
60
|
async configResolved({ configFileDependencies }) {
|
|
61
|
+
await checkForTempConfig();
|
|
62
|
+
|
|
75
63
|
configFileDependencies.forEach((file) => {
|
|
76
64
|
if (file.endsWith('siteconfig.js') || file.endsWith('template.js')) {
|
|
77
65
|
console.log('siteconfig or template changed');
|
|
@@ -94,11 +82,46 @@ export const updateConfig = async (config) => {
|
|
|
94
82
|
}
|
|
95
83
|
|
|
96
84
|
export const updateHandlebarsOnWatch = async (config) => {
|
|
97
|
-
const
|
|
85
|
+
const { isLocal, nodeEnv, buildPath } = defaultSettings;
|
|
86
|
+
// eslint-disable-next-line no-unused-vars
|
|
87
|
+
let tempConfigExists;
|
|
88
|
+
|
|
89
|
+
let mergedConfig = {
|
|
90
|
+
...config,
|
|
91
|
+
...footer(config),
|
|
92
|
+
...{ isLocal, nodeEnv, buildPath }
|
|
93
|
+
};
|
|
94
|
+
|
|
95
|
+
const checkForTempConfig = () => {
|
|
96
|
+
return new Promise((resolve) => {
|
|
97
|
+
tempConfigExists = fs.existsSync(`src/.tmp/config.json`);
|
|
98
|
+
|
|
99
|
+
const configData = fs.readFileSync('src/.tmp/config.json', 'utf8');
|
|
100
|
+
const parsedConfig = JSON.parse(configData);
|
|
101
|
+
mergedConfig = merge(parsedConfig, mergedConfig);
|
|
102
|
+
|
|
103
|
+
resolve();
|
|
104
|
+
});
|
|
105
|
+
};
|
|
98
106
|
|
|
99
107
|
return {
|
|
100
108
|
name: 'update-handlebars-reload',
|
|
101
109
|
enforce: 'pre',
|
|
110
|
+
async configResolved({ configFileDependencies }) {
|
|
111
|
+
await checkForTempConfig();
|
|
112
|
+
|
|
113
|
+
configFileDependencies.forEach((file) => {
|
|
114
|
+
if (file.endsWith('siteconfig.js') || file.endsWith('template.js')) {
|
|
115
|
+
console.log('siteconfig or template changed');
|
|
116
|
+
try {
|
|
117
|
+
// overwrite the config file with new data
|
|
118
|
+
fs.writeFileSync('src/.tmp/config.json', JSON.stringify(mergedConfig, null, 2));
|
|
119
|
+
} catch (error) {
|
|
120
|
+
console.error(`Error reading config file: ${error}`);
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
});
|
|
124
|
+
},
|
|
102
125
|
async handleHotUpdate({ server, file }) {
|
|
103
126
|
if (file.endsWith('.hbs') || file.endsWith('.html')) {
|
|
104
127
|
server.ws.send({
|