react-responsive-tools 2.0.15 → 2.1.0
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
CHANGED
@@ -0,0 +1,22 @@
|
|
1
|
+
// copyDefaultConfig.mjs
|
2
|
+
import fs from 'fs';
|
3
|
+
import path from 'path';
|
4
|
+
import { fileURLToPath } from 'url';
|
5
|
+
|
6
|
+
// Определение __filename и __dirname
|
7
|
+
const __filename = fileURLToPath(import.meta.url);
|
8
|
+
const __dirname = path.dirname(__filename);
|
9
|
+
|
10
|
+
// Путь к файлу конфигурации по умолчанию
|
11
|
+
const defaultConfigPath = path.resolve(__dirname, '../default.config.mjs');
|
12
|
+
|
13
|
+
// Путь для копии файла в корне проекта
|
14
|
+
const userConfigPath = path.resolve(__dirname, '../../../../breakpoints.config.js');
|
15
|
+
|
16
|
+
// Проверка, существует ли уже пользовательская конфигурация
|
17
|
+
if (!fs.existsSync(userConfigPath)) {
|
18
|
+
fs.copyFileSync(defaultConfigPath, userConfigPath);
|
19
|
+
console.log('Default configuration file has been copied to the root of the project as breakpoints.config.js');
|
20
|
+
} else {
|
21
|
+
console.log('User configuration file already exists.');
|
22
|
+
}
|
@@ -1,4 +1,4 @@
|
|
1
|
-
//
|
1
|
+
// createConfig.mjs
|
2
2
|
import fs from 'fs';
|
3
3
|
import path from 'path';
|
4
4
|
import { fileURLToPath } from 'url';
|
@@ -11,12 +11,6 @@ const __dirname = path.dirname(__filename);
|
|
11
11
|
// Путь к пользовательскому конфигурационному файлу
|
12
12
|
const userConfigPath = path.resolve(__dirname, '../../../../breakpoints.config.js');
|
13
13
|
|
14
|
-
// Функция объединения значений по умолчанию с пользовательскими значениями
|
15
|
-
const mergeConfigs = (defaultConfig, userConfig) => ({
|
16
|
-
...defaultConfig,
|
17
|
-
...userConfig,
|
18
|
-
});
|
19
|
-
|
20
14
|
const mergeBreakpointConfigs = async () => {
|
21
15
|
let horizontalBreakpoints = defaultHorizontalBreakpoints;
|
22
16
|
let verticalBreakpoints = defaultVerticalBreakpoints;
|
@@ -27,18 +21,20 @@ const mergeBreakpointConfigs = async () => {
|
|
27
21
|
console.log(`User config file found at: ${userConfigPath}`);
|
28
22
|
const userConfig = await import(userConfigPath);
|
29
23
|
console.log(`Loaded user config: ${JSON.stringify(userConfig, null, 2)}`);
|
30
|
-
console.log(`Default horizontal breakpoints: ${JSON.stringify(defaultHorizontalBreakpoints, null, 2)}`);
|
31
|
-
console.log(`Default vertical breakpoints: ${JSON.stringify(defaultVerticalBreakpoints, null, 2)}`);
|
32
|
-
|
33
|
-
console.log(`User horizontal breakpoints: ${JSON.stringify(userConfig.HORIZONTAL_BREAKPOINTS || {}, null, 2)}`);
|
34
|
-
console.log(`User vertical breakpoints: ${JSON.stringify(userConfig.VERTICAL_BREAKPOINTS || {}, null, 2)}`);
|
35
24
|
|
36
|
-
|
37
|
-
|
25
|
+
if (userConfig.HORIZONTAL_BREAKPOINTS) {
|
26
|
+
horizontalBreakpoints = userConfig.HORIZONTAL_BREAKPOINTS;
|
27
|
+
console.log('Using user provided horizontal breakpoints.');
|
28
|
+
} else {
|
29
|
+
console.log('Using default horizontal breakpoints.');
|
30
|
+
}
|
38
31
|
|
39
|
-
|
40
|
-
|
41
|
-
|
32
|
+
if (userConfig.VERTICAL_BREAKPOINTS) {
|
33
|
+
verticalBreakpoints = userConfig.VERTICAL_BREAKPOINTS;
|
34
|
+
console.log('Using user provided vertical breakpoints.');
|
35
|
+
} else {
|
36
|
+
console.log('Using default vertical breakpoints.');
|
37
|
+
}
|
42
38
|
} catch (error) {
|
43
39
|
console.error('Error loading user config:', error);
|
44
40
|
}
|