react-responsive-tools 2.0.9 → 2.0.11
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/package.json +1 -1
- package/src/scripts/createConfig.mjs +21 -8
package/package.json
CHANGED
@@ -9,12 +9,18 @@ const __filename = fileURLToPath(import.meta.url);
|
|
9
9
|
const __dirname = path.dirname(__filename);
|
10
10
|
|
11
11
|
// Путь к пользовательскому конфигурационному файлу
|
12
|
-
const userConfigPath = path.resolve(__dirname, '
|
12
|
+
const userConfigPath = path.resolve(__dirname, '../../../../breakpoints.config.js');
|
13
13
|
|
14
14
|
// Функция объединения значений по умолчанию с пользовательскими значениями
|
15
15
|
const mergeConfigs = (defaultConfig, userConfig) => ({
|
16
|
-
|
17
|
-
|
16
|
+
HORIZONTAL_BREAKPOINTS: {
|
17
|
+
...defaultConfig.HORIZONTAL_BREAKPOINTS,
|
18
|
+
...userConfig.HORIZONTAL_BREAKPOINTS,
|
19
|
+
},
|
20
|
+
VERTICAL_BREAKPOINTS: {
|
21
|
+
...defaultConfig.VERTICAL_BREAKPOINTS,
|
22
|
+
...userConfig.VERTICAL_BREAKPOINTS,
|
23
|
+
}
|
18
24
|
});
|
19
25
|
|
20
26
|
const mergeBreakpointConfigs = async () => {
|
@@ -24,19 +30,26 @@ const mergeBreakpointConfigs = async () => {
|
|
24
30
|
// Проверяем, существует ли пользовательский конфигурационный файл
|
25
31
|
if (fs.existsSync(userConfigPath)) {
|
26
32
|
try {
|
33
|
+
console.log(`User config file found at: ${userConfigPath}`);
|
27
34
|
const userConfig = await import(userConfigPath);
|
35
|
+
console.log(`User horizontal breakpoints: ${JSON.stringify(userConfig.HORIZONTAL_BREAKPOINTS || {}, null, 2)}`);
|
36
|
+
console.log(`User vertical breakpoints: ${JSON.stringify(userConfig.VERTICAL_BREAKPOINTS || {}, null, 2)}`);
|
37
|
+
|
28
38
|
horizontalBreakpoints = mergeConfigs(defaultHorizontalBreakpoints, userConfig.HORIZONTAL_BREAKPOINTS || {});
|
29
39
|
verticalBreakpoints = mergeConfigs(defaultVerticalBreakpoints, userConfig.VERTICAL_BREAKPOINTS || {});
|
40
|
+
|
41
|
+
console.log('Merged horizontal breakpoints: ', JSON.stringify(horizontalBreakpoints, null, 2));
|
42
|
+
console.log('Merged vertical breakpoints: ', JSON.stringify(verticalBreakpoints, null, 2));
|
30
43
|
console.log('User config loaded and merged successfully.');
|
31
44
|
} catch (error) {
|
32
45
|
console.error('Error loading user config:', error);
|
33
46
|
}
|
34
47
|
} else {
|
35
|
-
console.log(
|
48
|
+
console.log(`User config file not found at: ${userConfigPath}. Using default breakpoints.`);
|
36
49
|
}
|
37
50
|
|
38
51
|
const mergedConfigContent = `
|
39
|
-
// breakpoints.config.mjs
|
52
|
+
// custom-breakpoints.config.mjs
|
40
53
|
const HORIZONTAL_BREAKPOINTS = ${JSON.stringify(horizontalBreakpoints, null, 2)};
|
41
54
|
|
42
55
|
const VERTICAL_BREAKPOINTS = ${JSON.stringify(verticalBreakpoints, null, 2)};
|
@@ -45,9 +58,9 @@ export { HORIZONTAL_BREAKPOINTS, VERTICAL_BREAKPOINTS };
|
|
45
58
|
`;
|
46
59
|
|
47
60
|
try {
|
48
|
-
// Создаем новый файл с именем breakpoints.config.
|
49
|
-
fs.writeFileSync('../breakpoints.config.mjs', mergedConfigContent);
|
50
|
-
console.log('Config file
|
61
|
+
// Создаем новый файл с именем breakpoints.config.mjs
|
62
|
+
fs.writeFileSync(path.resolve(__dirname, '../breakpoints.config.mjs'), mergedConfigContent);
|
63
|
+
console.log('Config file has been generated successfully.');
|
51
64
|
} catch (error) {
|
52
65
|
console.error('Error writing merged config file:', error);
|
53
66
|
}
|