uglify-js-minify-css-allfiles 2.2.3 → 2.3.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.
@@ -0,0 +1,100 @@
1
+ /**
2
+ * Path resolution module for handling various file paths
3
+ * @module pathResolver
4
+ */
5
+
6
+ import path from 'path';
7
+ import { createRequire } from 'module';
8
+ import { fileURLToPath, pathToFileURL } from 'url';
9
+
10
+ const require = createRequire(import.meta.url);
11
+ const __filename = fileURLToPath(import.meta.url);
12
+ const __dirname = path.dirname(__filename);
13
+
14
+ /**
15
+ * Resolves a module path to a URL
16
+ * @param {string} moduleName - The name of the module to resolve
17
+ * @param {string} [baseDir] - Base directory for resolution (defaults to current directory)
18
+ * @returns {string} The resolved module path as a URL
19
+ */
20
+ export function resolveModulePath(moduleName, baseDir = __dirname) {
21
+ const modulePath = require.resolve(moduleName, { paths: [baseDir] });
22
+ return pathToFileURL(modulePath).href;
23
+ }
24
+
25
+ /**
26
+ * Resolves an image path relative to a source file
27
+ * @param {string} imagePath - Image path to resolve
28
+ * @param {string} sourceFilePath - Path of the source file
29
+ * @returns {string|null} Resolved absolute path or null for special cases
30
+ */
31
+ export function resolveImagePath(imagePath, sourceFilePath) {
32
+ // Remove query strings and hash fragments
33
+ imagePath = imagePath.split(/[?#]/)[0];
34
+
35
+ // Handle absolute paths
36
+ if (imagePath.startsWith('/')) {
37
+ return path.join(process.cwd(), imagePath);
38
+ }
39
+
40
+ // Handle data URIs
41
+ if (imagePath.startsWith('data:')) {
42
+ return null;
43
+ }
44
+
45
+ // Handle HTTP/HTTPS URLs
46
+ if (imagePath.startsWith('http://') || imagePath.startsWith('https://')) {
47
+ return null;
48
+ }
49
+
50
+ // Handle relative paths
51
+ return path.resolve(path.dirname(sourceFilePath), imagePath);
52
+ }
53
+
54
+ /**
55
+ * Makes a path relative to a base directory
56
+ * @param {string} fullPath - Full path to convert
57
+ * @param {string} baseDir - Base directory
58
+ * @returns {string} Relative path
59
+ */
60
+ export function makeRelativePath(fullPath, baseDir) {
61
+ return path.relative(baseDir, fullPath);
62
+ }
63
+
64
+ /**
65
+ * Gets a path's extension
66
+ * @param {string} filePath - Path to process
67
+ * @returns {string} File extension (with dot)
68
+ */
69
+ export function getExtension(filePath) {
70
+ return path.extname(filePath).toLowerCase();
71
+ }
72
+
73
+ /**
74
+ * Joins path segments
75
+ * @param {...string} paths - Path segments to join
76
+ * @returns {string} Joined path
77
+ */
78
+ export function joinPaths(...paths) {
79
+ return path.join(...paths);
80
+ }
81
+
82
+ /**
83
+ * Checks if a path contains a specific folder
84
+ * @param {string} filePath - Path to check
85
+ * @param {string} folderName - Folder name to look for
86
+ * @returns {boolean} Whether the path contains the folder
87
+ */
88
+ export function containsFolder(filePath, folderName) {
89
+ const normalizedPath = path.normalize(filePath);
90
+ return normalizedPath.includes(path.sep + folderName + path.sep) || normalizedPath.startsWith(folderName + path.sep);
91
+ }
92
+
93
+ /**
94
+ * Resolves a path to its absolute form
95
+ * @param {string} pathStr - Path to resolve
96
+ * @returns {string} Absolute path
97
+ */
98
+ export function resolvePath(pathStr) {
99
+ return path.resolve(pathStr);
100
+ }
@@ -0,0 +1,12 @@
1
+ [02/10/2025, 13:15:20] [INFO] Starting minification process {"contentPath":"./test/","excludeFolder":"lib","useBabel":{"targets":"chrome 40"}}
2
+ [02/10/2025, 13:15:21] [INFO] Writing file: C:\Users\PEARL\Desktop\_code\minify_contents\test\test.css
3
+ [02/10/2025, 13:15:21] [INFO] Writing file: C:\Users\PEARL\Desktop\_code\minify_contents\test\test.js
4
+ [02/10/2025, 13:15:21] [INFO] Processing Summary {"summary":{"totalFilesProcessed":2,"filesWithErrors":0,"errorCount":0,"errorFiles":[]}}
5
+ [02/10/2025, 13:16:03] [INFO] Starting minification process {"contentPath":"./test/","excludeFolder":"lib","useBabel":{"targets":"chrome 40"}}
6
+ [02/10/2025, 13:16:04] [INFO] Writing file: C:\Users\PEARL\Desktop\_code\minify_contents\test\test.css
7
+ [02/10/2025, 13:16:04] [INFO] Writing file: C:\Users\PEARL\Desktop\_code\minify_contents\test\test.js
8
+ [02/10/2025, 13:16:04] [INFO] Processing Summary {"summary":{"totalFilesProcessed":2,"filesWithErrors":0,"errorCount":0,"errorFiles":[]}}
9
+ [02/10/2025, 13:16:44] [INFO] Starting minification process {"contentPath":"./test/","excludeFolder":"lib","useBabel":{"targets":"chrome 40"}}
10
+ [02/10/2025, 13:16:45] [INFO] Writing file: C:\Users\PEARL\Desktop\_code\minify_contents\test\test.css
11
+ [02/10/2025, 13:16:45] [INFO] Writing file: C:\Users\PEARL\Desktop\_code\minify_contents\test\test.js
12
+ [02/10/2025, 13:16:45] [INFO] Processing Summary {"summary":{"totalFilesProcessed":2,"filesWithErrors":0,"errorCount":0,"errorFiles":[]}}