mod-build 4.0.1-beta.8b → 4.0.1
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 +2 -0
- package/package.json +1 -1
- package/src/scripts/plugins.js +26 -23
- package/tasks/clean.js +1 -1
package/CHANGELOG.md
CHANGED
package/package.json
CHANGED
package/src/scripts/plugins.js
CHANGED
|
@@ -33,10 +33,21 @@ export const STATIC_COPY_TARGETS = [
|
|
|
33
33
|
},
|
|
34
34
|
];
|
|
35
35
|
|
|
36
|
-
|
|
36
|
+
// eslint-disable-next-line no-unused-vars
|
|
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) => {
|
|
37
50
|
const { isLocal, nodeEnv, buildPath } = defaultSettings;
|
|
38
|
-
// eslint-disable-next-line no-unused-vars
|
|
39
|
-
let tempConfigExists;
|
|
40
51
|
|
|
41
52
|
let mergedConfig = {
|
|
42
53
|
...config,
|
|
@@ -44,33 +55,23 @@ export const updateConfig = async (config) => {
|
|
|
44
55
|
...{ isLocal, nodeEnv, buildPath }
|
|
45
56
|
};
|
|
46
57
|
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
if (
|
|
50
|
-
return undefined;
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
// Otherwise, use the default merging behavior
|
|
54
|
-
return merge(objValue, srcValue); // or you can return merge(objValue, srcValue) to merge nested objects
|
|
55
|
-
};
|
|
56
|
-
|
|
57
|
-
const checkForTempConfig = () => {
|
|
58
|
-
return new Promise((resolve) => {
|
|
59
|
-
tempConfigExists = fs.existsSync(`src/.tmp/config.json`);
|
|
60
|
-
|
|
58
|
+
return new Promise((resolve) => {
|
|
59
|
+
tempConfigExists = fs.existsSync(`src/.tmp/config.json`);
|
|
60
|
+
if (tempConfigExists) {
|
|
61
61
|
const configData = fs.readFileSync('src/.tmp/config.json', 'utf8');
|
|
62
62
|
const parsedConfig = JSON.parse(configData);
|
|
63
63
|
mergedConfig = mergeWith(parsedConfig, mergedConfig, customizer);
|
|
64
|
+
}
|
|
65
|
+
resolve(mergedConfig);
|
|
66
|
+
});
|
|
67
|
+
};
|
|
64
68
|
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
};
|
|
69
|
+
export const updateConfig = async (config) => {
|
|
70
|
+
const mergedConfig = await checkForTempConfig(config);
|
|
68
71
|
|
|
69
72
|
return {
|
|
70
73
|
name: 'update-config',
|
|
71
74
|
async configResolved({ configFileDependencies }) {
|
|
72
|
-
await checkForTempConfig();
|
|
73
|
-
|
|
74
75
|
configFileDependencies.forEach((file) => {
|
|
75
76
|
if (file.endsWith('siteconfig.js') || file.endsWith('template.js')) {
|
|
76
77
|
console.log('siteconfig or template changed');
|
|
@@ -93,6 +94,8 @@ export const updateConfig = async (config) => {
|
|
|
93
94
|
}
|
|
94
95
|
|
|
95
96
|
export const updateHandlebarsOnWatch = async (config) => {
|
|
97
|
+
const mergedConfig = await checkForTempConfig(config);
|
|
98
|
+
|
|
96
99
|
return {
|
|
97
100
|
name: 'update-handlebars-reload',
|
|
98
101
|
enforce: 'pre',
|
|
@@ -105,7 +108,7 @@ export const updateHandlebarsOnWatch = async (config) => {
|
|
|
105
108
|
}
|
|
106
109
|
},
|
|
107
110
|
transformIndexHtml: () => {
|
|
108
|
-
gulpHandlebarsFileInclude(
|
|
111
|
+
gulpHandlebarsFileInclude(mergedConfig, { maxRecursion: 500 });
|
|
109
112
|
}
|
|
110
113
|
}
|
|
111
114
|
}
|
package/tasks/clean.js
CHANGED