uglify-js-minify-css-allfiles 2.1.0 → 2.2.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/CHANGELOG.md +20 -1
- package/README.md +51 -23
- package/dist/module.js +60 -21
- package/dist/modules/minifier.js +20 -13
- package/logs/log-08-21-2024.log +80 -0
- package/minify.d.ts +127 -3
- package/package.json +4 -1
- package/.vscode/settings.json +0 -13
package/CHANGELOG.md
CHANGED
|
@@ -5,6 +5,24 @@ All notable changes to this project will be documented in this file.
|
|
|
5
5
|
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
|
|
6
6
|
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
|
7
7
|
|
|
8
|
+
## [2.2.0] - 2024-08-21
|
|
9
|
+
|
|
10
|
+
### Added
|
|
11
|
+
|
|
12
|
+
- Customizable minification options for both JavaScript and CSS
|
|
13
|
+
- New `jsMinifyOptions` parameter to allow fine-tuning of JavaScript minification
|
|
14
|
+
- New `cssMinifyOptions` parameter to allow fine-tuning of CSS minification
|
|
15
|
+
|
|
16
|
+
### Changed
|
|
17
|
+
|
|
18
|
+
- Updated `minifyAll` function to accept and use new minification options
|
|
19
|
+
- Refactored `FILE_HANDLERS` to accommodate new options
|
|
20
|
+
- Updated documentation to reflect new customization capabilities
|
|
21
|
+
|
|
22
|
+
### Improved
|
|
23
|
+
|
|
24
|
+
- Enhanced flexibility in minification process, allowing users to tailor the process to their specific needs
|
|
25
|
+
|
|
8
26
|
## [2.1.0] - 2024-08-20
|
|
9
27
|
|
|
10
28
|
### Changed
|
|
@@ -88,10 +106,11 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
|
88
106
|
- New `exceptFolder` parameter to exclude specific folders from minification
|
|
89
107
|
- Support for using relative paths
|
|
90
108
|
|
|
109
|
+
[2.2.0]: https://github.com/oinochoe/uglify-js-minify-css-allfiles/compare/v2.1.0...v2.2.0
|
|
91
110
|
[2.1.0]: https://github.com/oinochoe/uglify-js-minify-css-allfiles/compare/v2.0.0...v2.1.0
|
|
92
111
|
[2.0.0]: https://github.com/oinochoe/uglify-js-minify-css-allfiles/compare/v1.3.2...v2.0.0
|
|
93
112
|
[1.3.2]: https://github.com/oinochoe/uglify-js-minify-css-allfiles/compare/v1.3.1...v1.3.2
|
|
94
113
|
[1.3.1]: https://github.com/oinochoe/uglify-js-minify-css-allfiles/compare/v1.3.0...v1.3.1
|
|
95
114
|
[1.3.0]: https://github.com/oinochoe/uglify-js-minify-css-allfiles/compare/v1.2.0...v1.3.0
|
|
96
115
|
[1.2.0]: https://github.com/oinochoe/uglify-js-minify-css-allfiles/compare/v1.1.0...v1.2.0
|
|
97
|
-
[1.1.0]: https://github.com/oinochoe/uglify-js-minify-css-allfiles/
|
|
116
|
+
[1.1.0]: https://github.com/oinochoe/uglify-js-minify-css-allfiles/releases/tag/v1.1.0
|
package/README.md
CHANGED
|
@@ -27,6 +27,7 @@ You can easily minify all files in a specific folder, with the option to exclude
|
|
|
27
27
|
- [Usage](#usage)
|
|
28
28
|
- [Parameters](#parameters)
|
|
29
29
|
- [Options](#options)
|
|
30
|
+
- [Minification Options](#minification-options)
|
|
30
31
|
- [Changelog](#changelog)
|
|
31
32
|
- [License](#license)
|
|
32
33
|
|
|
@@ -70,24 +71,27 @@ $ npm i uglify-js-minify-css-allfiles
|
|
|
70
71
|
logToConsole: true,
|
|
71
72
|
logToFile: true,
|
|
72
73
|
},
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
74
|
+
jsMinifyOptions: {
|
|
75
|
+
compress: {
|
|
76
|
+
dead_code: true,
|
|
77
|
+
drop_debugger: true,
|
|
78
|
+
conditionals: true,
|
|
79
|
+
evaluate: true,
|
|
80
|
+
booleans: true,
|
|
81
|
+
loops: true,
|
|
82
|
+
unused: true,
|
|
83
|
+
hoist_funs: true,
|
|
84
|
+
keep_fargs: false,
|
|
85
|
+
hoist_vars: true,
|
|
86
|
+
if_return: true,
|
|
87
|
+
join_vars: true,
|
|
88
|
+
cascade: true,
|
|
89
|
+
side_effects: true,
|
|
90
|
+
warnings: false,
|
|
91
|
+
},
|
|
92
|
+
},
|
|
93
|
+
cssMinifyOptions: {
|
|
94
|
+
level: 2,
|
|
91
95
|
},
|
|
92
96
|
});
|
|
93
97
|
```
|
|
@@ -105,11 +109,13 @@ The `minifyAll` function accepts the following parameters:
|
|
|
105
109
|
|
|
106
110
|
The `options` object can have the following properties:
|
|
107
111
|
|
|
108
|
-
| Property
|
|
109
|
-
|
|
|
110
|
-
| `excludeFolder`
|
|
111
|
-
| `useBabel`
|
|
112
|
-
| `useLog`
|
|
112
|
+
| Property | Type | Default | Description |
|
|
113
|
+
| ------------------ | ----------------- | ------- | ------------------------------------------------------------------------------------------ |
|
|
114
|
+
| `excludeFolder` | string | `''` | The name of a folder to exclude from minification. |
|
|
115
|
+
| `useBabel` | boolean \| object | `false` | If `true`, enables Babel with default settings. If an object, specifies Babel options. |
|
|
116
|
+
| `useLog` | boolean \| object | `true` | If `true`, enables logging with default settings. If an object, specifies logging options. |
|
|
117
|
+
| `jsMinifyOptions` | object | `{}` | Options for JavaScript minification (passed to UglifyJS). |
|
|
118
|
+
| `cssMinifyOptions` | object | `{}` | Options for CSS minification (passed to CleanCSS). |
|
|
113
119
|
|
|
114
120
|
### Babel Options
|
|
115
121
|
|
|
@@ -137,6 +143,28 @@ When `useLog` is an object, it can have the following properties:
|
|
|
137
143
|
| `logToConsole` | boolean | `true` | Determines if logs should also be output to the console. |
|
|
138
144
|
| `logToFile` | boolean | `true` | Determines if logs should be written to a file. |
|
|
139
145
|
|
|
146
|
+
## Minification Options
|
|
147
|
+
|
|
148
|
+
### JavaScript Minification Options
|
|
149
|
+
|
|
150
|
+
The `jsMinifyOptions` object is passed directly to UglifyJS. For a full list of available options, please refer to the [UglifyJS documentation](https://github.com/mishoo/UglifyJS#minify-options).
|
|
151
|
+
|
|
152
|
+
Some commonly used options include:
|
|
153
|
+
|
|
154
|
+
- `compress`: An object specifying compression options.
|
|
155
|
+
- `mangle`: Controls name mangling. Can be a boolean or an object with more specific options.
|
|
156
|
+
- `output`: An object controlling the output format.
|
|
157
|
+
|
|
158
|
+
### CSS Minification Options
|
|
159
|
+
|
|
160
|
+
The `cssMinifyOptions` object is passed directly to Clean-CSS. For a full list of available options, please refer to the [Clean-CSS documentation](https://github.com/clean-css/clean-css#constructor-options).
|
|
161
|
+
|
|
162
|
+
Some commonly used options include:
|
|
163
|
+
|
|
164
|
+
- `level`: Optimization level (0, 1, or 2).
|
|
165
|
+
- `compatibility`: Browser compatibility (e.g., 'ie7', '\*').
|
|
166
|
+
- `format`: Output formatting options.
|
|
167
|
+
|
|
140
168
|
## Changelog
|
|
141
169
|
|
|
142
170
|
See CHANGELOG.md for details on each release.
|
package/dist/module.js
CHANGED
|
@@ -11,22 +11,48 @@ import { getAllFiles, writeFile } from './modules/fileHandler.js';
|
|
|
11
11
|
import { minifyJS, minifyCSS } from './modules/minifier.js';
|
|
12
12
|
import babelCore from '@babel/core';
|
|
13
13
|
|
|
14
|
+
/**
|
|
15
|
+
* Object containing handlers for different file types.
|
|
16
|
+
* @type {Object.<string, function>}
|
|
17
|
+
*/
|
|
14
18
|
const FILE_HANDLERS = {
|
|
15
|
-
|
|
19
|
+
/**
|
|
20
|
+
* Handles JavaScript file minification.
|
|
21
|
+
* @async
|
|
22
|
+
* @param {string} filePath - The path of the JavaScript file.
|
|
23
|
+
* @param {string} content - The content of the JavaScript file.
|
|
24
|
+
* @param {Logger} logger - The logger instance.
|
|
25
|
+
* @param {Object} options - Options for processing.
|
|
26
|
+
* @param {Object} [options.babelOptions] - Babel transformation options.
|
|
27
|
+
* @param {Object} [options.jsMinifyOptions] - JavaScript minification options.
|
|
28
|
+
* @returns {Promise<void>}
|
|
29
|
+
*/
|
|
30
|
+
'.js': async (filePath, content, logger, options) => {
|
|
16
31
|
try {
|
|
17
32
|
let transformed = content;
|
|
18
|
-
if (babelOptions) {
|
|
19
|
-
transformed = babelCore.transformSync(content, babelOptions).code;
|
|
33
|
+
if (options.babelOptions) {
|
|
34
|
+
transformed = babelCore.transformSync(content, options.babelOptions).code;
|
|
20
35
|
}
|
|
21
|
-
const result = minifyJS(transformed);
|
|
36
|
+
const result = minifyJS(transformed, options.jsMinifyOptions);
|
|
22
37
|
await writeFile(filePath, result, logger);
|
|
23
38
|
} catch (error) {
|
|
24
39
|
await logger?.error('JavaScript minification failed', { filePath, error: error.message });
|
|
25
40
|
}
|
|
26
41
|
},
|
|
27
|
-
|
|
42
|
+
|
|
43
|
+
/**
|
|
44
|
+
* Handles CSS file minification.
|
|
45
|
+
* @async
|
|
46
|
+
* @param {string} filePath - The path of the CSS file.
|
|
47
|
+
* @param {string} content - The content of the CSS file.
|
|
48
|
+
* @param {Logger} logger - The logger instance.
|
|
49
|
+
* @param {Object} options - Options for processing.
|
|
50
|
+
* @param {Object} [options.cssMinifyOptions] - CSS minification options.
|
|
51
|
+
* @returns {Promise<void>}
|
|
52
|
+
*/
|
|
53
|
+
'.css': async (filePath, content, logger, options) => {
|
|
28
54
|
try {
|
|
29
|
-
const output = await minifyCSS(content);
|
|
55
|
+
const output = await minifyCSS(content, options.cssMinifyOptions);
|
|
30
56
|
if (0 < output.warnings.length) {
|
|
31
57
|
await logger?.warn('CSS minification warnings', { filePath, warnings: output.warnings });
|
|
32
58
|
}
|
|
@@ -42,17 +68,17 @@ const FILE_HANDLERS = {
|
|
|
42
68
|
* @async
|
|
43
69
|
* @param {string} filePath - The path of the file to process.
|
|
44
70
|
* @param {Logger} logger - The logger instance.
|
|
45
|
-
* @param {Object}
|
|
71
|
+
* @param {Object} options - Options for processing.
|
|
46
72
|
* @returns {Promise<void>}
|
|
47
73
|
*/
|
|
48
|
-
async function processFile(filePath, logger,
|
|
74
|
+
async function processFile(filePath, logger, options) {
|
|
49
75
|
try {
|
|
50
76
|
const fileContent = await fs.readFile(filePath, 'utf-8');
|
|
51
77
|
const fileExtension = path.extname(filePath).toLowerCase();
|
|
52
78
|
const handler = FILE_HANDLERS[fileExtension];
|
|
53
79
|
|
|
54
80
|
if (handler) {
|
|
55
|
-
await handler(filePath, fileContent, logger,
|
|
81
|
+
await handler(filePath, fileContent, logger, options);
|
|
56
82
|
} else {
|
|
57
83
|
await logger?.info(`Unsupported file type, skipping: ${filePath}`);
|
|
58
84
|
}
|
|
@@ -63,8 +89,7 @@ async function processFile(filePath, logger, babelOptions = null) {
|
|
|
63
89
|
|
|
64
90
|
/**
|
|
65
91
|
* Resolves Babel options based on the provided configuration.
|
|
66
|
-
*
|
|
67
|
-
* @param {Object|null} useBabel - The Babel options object or null.
|
|
92
|
+
* @param {boolean|Object} useBabel - The Babel options object or boolean.
|
|
68
93
|
* @returns {Object|null} The resolved Babel options or null if no valid options are provided.
|
|
69
94
|
*/
|
|
70
95
|
function resolveBabelOptions(useBabel) {
|
|
@@ -106,11 +131,12 @@ function resolveBabelOptions(useBabel) {
|
|
|
106
131
|
|
|
107
132
|
/**
|
|
108
133
|
* Options for minification configuration.
|
|
109
|
-
*
|
|
110
134
|
* @typedef {Object} MinifyOptions
|
|
111
|
-
* @property {string} [excludeFolder] - Folder to exclude from minification.
|
|
112
|
-
* @property {boolean|
|
|
113
|
-
* @property {boolean|
|
|
135
|
+
* @property {string} [excludeFolder=''] - Folder to exclude from minification.
|
|
136
|
+
* @property {boolean|Object} [useBabel=false] - Whether to use Babel for transformation, and the options for Babel if used.
|
|
137
|
+
* @property {boolean|Object} [useLog=true] - Whether to use logging, and the options for logging if used.
|
|
138
|
+
* @property {Object} [jsMinifyOptions={}] - Options for JavaScript minification.
|
|
139
|
+
* @property {Object} [cssMinifyOptions={}] - Options for CSS minification.
|
|
114
140
|
*/
|
|
115
141
|
|
|
116
142
|
/**
|
|
@@ -124,17 +150,30 @@ function resolveBabelOptions(useBabel) {
|
|
|
124
150
|
* @throws {Error} If there's an issue reading or writing files.
|
|
125
151
|
*/
|
|
126
152
|
export default async function minifyAll(contentPath, options = {}) {
|
|
127
|
-
const {
|
|
153
|
+
const {
|
|
154
|
+
excludeFolder = '',
|
|
155
|
+
useBabel = false,
|
|
156
|
+
useLog = true,
|
|
157
|
+
jsMinifyOptions = {},
|
|
158
|
+
cssMinifyOptions = {},
|
|
159
|
+
} = options;
|
|
128
160
|
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
161
|
+
let logger = null;
|
|
162
|
+
if (useLog) {
|
|
163
|
+
const logOptions = typeof useLog === 'object' ? useLog : {};
|
|
164
|
+
logger = new Logger(logOptions);
|
|
132
165
|
await logger.initialize();
|
|
133
166
|
await logger.info('Starting minification process', { contentPath, excludeFolder, useBabel });
|
|
134
167
|
}
|
|
135
168
|
|
|
136
169
|
const rootDir = path.resolve(contentPath || '');
|
|
137
|
-
const
|
|
170
|
+
const babelOptions = resolveBabelOptions(useBabel);
|
|
171
|
+
|
|
172
|
+
const processOptions = {
|
|
173
|
+
babelOptions,
|
|
174
|
+
jsMinifyOptions,
|
|
175
|
+
cssMinifyOptions,
|
|
176
|
+
};
|
|
138
177
|
|
|
139
178
|
try {
|
|
140
179
|
await getAllFiles(rootDir, async (filePath) => {
|
|
@@ -143,7 +182,7 @@ export default async function minifyAll(contentPath, options = {}) {
|
|
|
143
182
|
return;
|
|
144
183
|
}
|
|
145
184
|
|
|
146
|
-
await processFile(filePath, logger,
|
|
185
|
+
await processFile(filePath, logger, processOptions);
|
|
147
186
|
logger?.incrementProcessedFiles(filePath);
|
|
148
187
|
});
|
|
149
188
|
} catch (error) {
|
package/dist/modules/minifier.js
CHANGED
|
@@ -6,26 +6,26 @@
|
|
|
6
6
|
import { minify as uglifyJS } from 'uglify-js';
|
|
7
7
|
import CleanCSS from 'clean-css';
|
|
8
8
|
|
|
9
|
-
/**
|
|
10
|
-
* Options for CSS minification.
|
|
11
|
-
* @constant {Object}
|
|
12
|
-
*/
|
|
13
|
-
const CSS_OPTIONS = {
|
|
14
|
-
level: { 1: { all: false } },
|
|
15
|
-
};
|
|
16
|
-
|
|
17
9
|
/**
|
|
18
10
|
* Minifies JavaScript content.
|
|
19
11
|
*
|
|
20
12
|
* @param {string} content - The JavaScript content to minify.
|
|
13
|
+
* @param {Object} options - Options for JavaScript minification.
|
|
21
14
|
* @returns {string} The minified JavaScript content.
|
|
22
15
|
*/
|
|
23
|
-
export function minifyJS(content) {
|
|
24
|
-
|
|
16
|
+
export function minifyJS(content, options = {}) {
|
|
17
|
+
const defaultOptions = {
|
|
25
18
|
compress: {
|
|
26
19
|
pure_funcs: ['console.log', 'console.error', 'console.warn', 'console.info'],
|
|
20
|
+
module: false,
|
|
21
|
+
arrows: false,
|
|
22
|
+
drop_debugger: true,
|
|
27
23
|
},
|
|
28
|
-
|
|
24
|
+
ie8: false,
|
|
25
|
+
};
|
|
26
|
+
|
|
27
|
+
const mergedOptions = { ...defaultOptions, ...options };
|
|
28
|
+
return uglifyJS(content, mergedOptions).code;
|
|
29
29
|
}
|
|
30
30
|
|
|
31
31
|
/**
|
|
@@ -33,10 +33,17 @@ export function minifyJS(content) {
|
|
|
33
33
|
*
|
|
34
34
|
* @async
|
|
35
35
|
* @param {string} content - The CSS content to minify.
|
|
36
|
+
* @param {Object} options - Options for CSS minification.
|
|
36
37
|
* @returns {Promise<Object>} A promise that resolves to the minification result.
|
|
37
38
|
*/
|
|
38
|
-
export function minifyCSS(content) {
|
|
39
|
+
export function minifyCSS(content, options = {}) {
|
|
40
|
+
const defaultOptions = {
|
|
41
|
+
level: { 1: { all: false } },
|
|
42
|
+
};
|
|
43
|
+
|
|
44
|
+
const mergedOptions = { ...defaultOptions, ...options };
|
|
45
|
+
|
|
39
46
|
return new Promise((resolve) => {
|
|
40
|
-
new CleanCSS(
|
|
47
|
+
new CleanCSS(mergedOptions).minify(content, (error, output) => resolve(output));
|
|
41
48
|
});
|
|
42
49
|
}
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
[08/21/2024, 04:47:18] [INFO] Starting minification process {"contentPath":"./test/","excludeFolder":"lib","useBabel":{"targets":"chrome 40"}}
|
|
2
|
+
[08/21/2024, 04:47:18] [INFO] Writing file: C:\Users\PEARL\Desktop\uglify-js-minify-css-allfiles\test\test.css
|
|
3
|
+
[08/21/2024, 04:47:19] [INFO] Writing file: C:\Users\PEARL\Desktop\uglify-js-minify-css-allfiles\test\test.js
|
|
4
|
+
[08/21/2024, 04:47:19] [INFO] Processing Summary {"summary":{"totalFilesProcessed":2,"filesWithErrors":0,"errorCount":0,"errorFiles":[]}}
|
|
5
|
+
[08/21/2024, 04:48:46] [INFO] Starting minification process {"contentPath":"./test/","excludeFolder":"lib","useBabel":{"targets":"chrome 40"}}
|
|
6
|
+
[08/21/2024, 04:48:46] [INFO] Writing file: C:\Users\PEARL\Desktop\uglify-js-minify-css-allfiles\test\test.css
|
|
7
|
+
[08/21/2024, 04:48:47] [INFO] Writing file: C:\Users\PEARL\Desktop\uglify-js-minify-css-allfiles\test\test.js
|
|
8
|
+
[08/21/2024, 04:48:47] [INFO] Processing Summary {"summary":{"totalFilesProcessed":2,"filesWithErrors":0,"errorCount":0,"errorFiles":[]}}
|
|
9
|
+
[08/21/2024, 04:53:29] [INFO] Starting minification process {"contentPath":"./test/","excludeFolder":"lib","useBabel":{"targets":"chrome 40"}}
|
|
10
|
+
[08/21/2024, 04:53:29] [INFO] Writing file: C:\Users\PEARL\Desktop\uglify-js-minify-css-allfiles\test\test.css
|
|
11
|
+
[08/21/2024, 04:53:30] [ERROR] Invalid or empty content {"filePath":"C:\\Users\\PEARL\\Desktop\\uglify-js-minify-css-allfiles\\test\\test.js"}
|
|
12
|
+
[08/21/2024, 04:53:30] [INFO] Processing Summary {"summary":{"totalFilesProcessed":2,"filesWithErrors":1,"errorCount":1,"errorFiles":["C:\\Users\\PEARL\\Desktop\\uglify-js-minify-css-allfiles\\test\\test.js"]}}
|
|
13
|
+
[08/21/2024, 04:53:47] [INFO] Starting minification process {"contentPath":"./test/","excludeFolder":"lib","useBabel":{"targets":"chrome 40"}}
|
|
14
|
+
[08/21/2024, 04:53:47] [INFO] Writing file: C:\Users\PEARL\Desktop\uglify-js-minify-css-allfiles\test\test.css
|
|
15
|
+
[08/21/2024, 04:53:48] [ERROR] Invalid or empty content {"filePath":"C:\\Users\\PEARL\\Desktop\\uglify-js-minify-css-allfiles\\test\\test.js"}
|
|
16
|
+
[08/21/2024, 04:53:48] [INFO] Processing Summary {"summary":{"totalFilesProcessed":2,"filesWithErrors":1,"errorCount":1,"errorFiles":["C:\\Users\\PEARL\\Desktop\\uglify-js-minify-css-allfiles\\test\\test.js"]}}
|
|
17
|
+
[08/21/2024, 04:55:05] [INFO] Starting minification process {"contentPath":"./test/","excludeFolder":"lib","useBabel":{"targets":"chrome 40"}}
|
|
18
|
+
[08/21/2024, 04:55:05] [INFO] Writing file: C:\Users\PEARL\Desktop\uglify-js-minify-css-allfiles\test\test.css
|
|
19
|
+
[08/21/2024, 04:55:06] [ERROR] Invalid or empty content {"filePath":"C:\\Users\\PEARL\\Desktop\\uglify-js-minify-css-allfiles\\test\\test.js"}
|
|
20
|
+
[08/21/2024, 04:55:06] [INFO] Processing Summary {"summary":{"totalFilesProcessed":2,"filesWithErrors":1,"errorCount":1,"errorFiles":["C:\\Users\\PEARL\\Desktop\\uglify-js-minify-css-allfiles\\test\\test.js"]}}
|
|
21
|
+
[08/21/2024, 04:55:21] [INFO] Starting minification process {"contentPath":"./test/","excludeFolder":"lib","useBabel":{"targets":"chrome 40"}}
|
|
22
|
+
[08/21/2024, 04:55:21] [INFO] Writing file: C:\Users\PEARL\Desktop\uglify-js-minify-css-allfiles\test\test.css
|
|
23
|
+
[08/21/2024, 04:55:22] [ERROR] Invalid or empty content {"filePath":"C:\\Users\\PEARL\\Desktop\\uglify-js-minify-css-allfiles\\test\\test.js"}
|
|
24
|
+
[08/21/2024, 04:55:22] [INFO] Processing Summary {"summary":{"totalFilesProcessed":2,"filesWithErrors":1,"errorCount":1,"errorFiles":["C:\\Users\\PEARL\\Desktop\\uglify-js-minify-css-allfiles\\test\\test.js"]}}
|
|
25
|
+
[08/21/2024, 04:55:30] [INFO] Starting minification process {"contentPath":"./test/","excludeFolder":"lib","useBabel":{"targets":"chrome 40"}}
|
|
26
|
+
[08/21/2024, 04:55:30] [INFO] Writing file: C:\Users\PEARL\Desktop\uglify-js-minify-css-allfiles\test\test.css
|
|
27
|
+
[08/21/2024, 04:55:31] [ERROR] Invalid or empty content {"filePath":"C:\\Users\\PEARL\\Desktop\\uglify-js-minify-css-allfiles\\test\\test.js"}
|
|
28
|
+
[08/21/2024, 04:55:31] [INFO] Processing Summary {"summary":{"totalFilesProcessed":2,"filesWithErrors":1,"errorCount":1,"errorFiles":["C:\\Users\\PEARL\\Desktop\\uglify-js-minify-css-allfiles\\test\\test.js"]}}
|
|
29
|
+
[08/21/2024, 04:55:37] [INFO] Starting minification process {"contentPath":"./test/","excludeFolder":"lib","useBabel":{"targets":"chrome 40"}}
|
|
30
|
+
[08/21/2024, 04:55:37] [INFO] Writing file: C:\Users\PEARL\Desktop\uglify-js-minify-css-allfiles\test\test.css
|
|
31
|
+
[08/21/2024, 04:55:38] [ERROR] Invalid or empty content {"filePath":"C:\\Users\\PEARL\\Desktop\\uglify-js-minify-css-allfiles\\test\\test.js"}
|
|
32
|
+
[08/21/2024, 04:55:38] [INFO] Processing Summary {"summary":{"totalFilesProcessed":2,"filesWithErrors":1,"errorCount":1,"errorFiles":["C:\\Users\\PEARL\\Desktop\\uglify-js-minify-css-allfiles\\test\\test.js"]}}
|
|
33
|
+
[08/21/2024, 04:55:46] [INFO] Starting minification process {"contentPath":"./test/","excludeFolder":"lib","useBabel":{"targets":"chrome 40"}}
|
|
34
|
+
[08/21/2024, 04:55:46] [INFO] Writing file: C:\Users\PEARL\Desktop\uglify-js-minify-css-allfiles\test\test.css
|
|
35
|
+
[08/21/2024, 04:55:47] [ERROR] Invalid or empty content {"filePath":"C:\\Users\\PEARL\\Desktop\\uglify-js-minify-css-allfiles\\test\\test.js"}
|
|
36
|
+
[08/21/2024, 04:55:47] [INFO] Processing Summary {"summary":{"totalFilesProcessed":2,"filesWithErrors":1,"errorCount":1,"errorFiles":["C:\\Users\\PEARL\\Desktop\\uglify-js-minify-css-allfiles\\test\\test.js"]}}
|
|
37
|
+
[08/21/2024, 04:56:00] [INFO] Starting minification process {"contentPath":"./test/","excludeFolder":"lib","useBabel":{"targets":"chrome 40"}}
|
|
38
|
+
[08/21/2024, 04:56:00] [INFO] Writing file: C:\Users\PEARL\Desktop\uglify-js-minify-css-allfiles\test\test.css
|
|
39
|
+
[08/21/2024, 04:56:01] [ERROR] Invalid or empty content {"filePath":"C:\\Users\\PEARL\\Desktop\\uglify-js-minify-css-allfiles\\test\\test.js"}
|
|
40
|
+
[08/21/2024, 04:56:01] [INFO] Processing Summary {"summary":{"totalFilesProcessed":2,"filesWithErrors":1,"errorCount":1,"errorFiles":["C:\\Users\\PEARL\\Desktop\\uglify-js-minify-css-allfiles\\test\\test.js"]}}
|
|
41
|
+
[08/21/2024, 04:56:21] [INFO] Starting minification process {"contentPath":"./test/","excludeFolder":"lib","useBabel":{"targets":"chrome 40"}}
|
|
42
|
+
[08/21/2024, 04:56:21] [INFO] Writing file: C:\Users\PEARL\Desktop\uglify-js-minify-css-allfiles\test\test.css
|
|
43
|
+
[08/21/2024, 04:56:22] [INFO] Writing file: C:\Users\PEARL\Desktop\uglify-js-minify-css-allfiles\test\test.js
|
|
44
|
+
[08/21/2024, 04:56:22] [INFO] Processing Summary {"summary":{"totalFilesProcessed":2,"filesWithErrors":0,"errorCount":0,"errorFiles":[]}}
|
|
45
|
+
[08/21/2024, 04:56:30] [INFO] Starting minification process {"contentPath":"./test/","excludeFolder":"lib","useBabel":{"targets":"chrome 40"}}
|
|
46
|
+
[08/21/2024, 04:56:30] [INFO] Writing file: C:\Users\PEARL\Desktop\uglify-js-minify-css-allfiles\test\test.css
|
|
47
|
+
[08/21/2024, 04:56:30] [ERROR] Invalid or empty content {"filePath":"C:\\Users\\PEARL\\Desktop\\uglify-js-minify-css-allfiles\\test\\test.js"}
|
|
48
|
+
[08/21/2024, 04:56:30] [INFO] Processing Summary {"summary":{"totalFilesProcessed":2,"filesWithErrors":1,"errorCount":1,"errorFiles":["C:\\Users\\PEARL\\Desktop\\uglify-js-minify-css-allfiles\\test\\test.js"]}}
|
|
49
|
+
[08/21/2024, 04:56:38] [INFO] Starting minification process {"contentPath":"./test/","excludeFolder":"lib","useBabel":{"targets":"chrome 40"}}
|
|
50
|
+
[08/21/2024, 04:56:38] [INFO] Writing file: C:\Users\PEARL\Desktop\uglify-js-minify-css-allfiles\test\test.css
|
|
51
|
+
[08/21/2024, 04:56:39] [ERROR] Invalid or empty content {"filePath":"C:\\Users\\PEARL\\Desktop\\uglify-js-minify-css-allfiles\\test\\test.js"}
|
|
52
|
+
[08/21/2024, 04:56:39] [INFO] Processing Summary {"summary":{"totalFilesProcessed":2,"filesWithErrors":1,"errorCount":1,"errorFiles":["C:\\Users\\PEARL\\Desktop\\uglify-js-minify-css-allfiles\\test\\test.js"]}}
|
|
53
|
+
[08/21/2024, 04:56:48] [INFO] Starting minification process {"contentPath":"./test/","excludeFolder":"lib","useBabel":{"targets":"chrome 40"}}
|
|
54
|
+
[08/21/2024, 04:56:48] [INFO] Writing file: C:\Users\PEARL\Desktop\uglify-js-minify-css-allfiles\test\test.css
|
|
55
|
+
[08/21/2024, 04:56:49] [INFO] Writing file: C:\Users\PEARL\Desktop\uglify-js-minify-css-allfiles\test\test.js
|
|
56
|
+
[08/21/2024, 04:56:49] [INFO] Processing Summary {"summary":{"totalFilesProcessed":2,"filesWithErrors":0,"errorCount":0,"errorFiles":[]}}
|
|
57
|
+
[08/21/2024, 04:59:02] [INFO] Starting minification process {"contentPath":"./test/","excludeFolder":"lib","useBabel":{"targets":"chrome 40"}}
|
|
58
|
+
[08/21/2024, 04:59:02] [INFO] Writing file: C:\Users\PEARL\Desktop\uglify-js-minify-css-allfiles\test\test.css
|
|
59
|
+
[08/21/2024, 04:59:03] [ERROR] Invalid or empty content {"filePath":"C:\\Users\\PEARL\\Desktop\\uglify-js-minify-css-allfiles\\test\\test.js"}
|
|
60
|
+
[08/21/2024, 04:59:03] [INFO] Processing Summary {"summary":{"totalFilesProcessed":2,"filesWithErrors":1,"errorCount":1,"errorFiles":["C:\\Users\\PEARL\\Desktop\\uglify-js-minify-css-allfiles\\test\\test.js"]}}
|
|
61
|
+
[08/21/2024, 04:59:23] [INFO] Starting minification process {"contentPath":"./test/","excludeFolder":"lib","useBabel":{"targets":"chrome 40"}}
|
|
62
|
+
[08/21/2024, 04:59:23] [INFO] Writing file: C:\Users\PEARL\Desktop\uglify-js-minify-css-allfiles\test\test.css
|
|
63
|
+
[08/21/2024, 04:59:24] [ERROR] Invalid or empty content {"filePath":"C:\\Users\\PEARL\\Desktop\\uglify-js-minify-css-allfiles\\test\\test.js"}
|
|
64
|
+
[08/21/2024, 04:59:24] [INFO] Processing Summary {"summary":{"totalFilesProcessed":2,"filesWithErrors":1,"errorCount":1,"errorFiles":["C:\\Users\\PEARL\\Desktop\\uglify-js-minify-css-allfiles\\test\\test.js"]}}
|
|
65
|
+
[08/21/2024, 04:59:33] [INFO] Starting minification process {"contentPath":"./test/","excludeFolder":"lib","useBabel":{"targets":"chrome 40"}}
|
|
66
|
+
[08/21/2024, 04:59:33] [INFO] Writing file: C:\Users\PEARL\Desktop\uglify-js-minify-css-allfiles\test\test.css
|
|
67
|
+
[08/21/2024, 04:59:34] [INFO] Writing file: C:\Users\PEARL\Desktop\uglify-js-minify-css-allfiles\test\test.js
|
|
68
|
+
[08/21/2024, 04:59:34] [INFO] Processing Summary {"summary":{"totalFilesProcessed":2,"filesWithErrors":0,"errorCount":0,"errorFiles":[]}}
|
|
69
|
+
[08/21/2024, 04:59:49] [INFO] Starting minification process {"contentPath":"./test/","excludeFolder":"lib","useBabel":{"targets":"chrome 40"}}
|
|
70
|
+
[08/21/2024, 04:59:49] [INFO] Writing file: C:\Users\PEARL\Desktop\uglify-js-minify-css-allfiles\test\test.css
|
|
71
|
+
[08/21/2024, 04:59:50] [ERROR] Invalid or empty content {"filePath":"C:\\Users\\PEARL\\Desktop\\uglify-js-minify-css-allfiles\\test\\test.js"}
|
|
72
|
+
[08/21/2024, 04:59:50] [INFO] Processing Summary {"summary":{"totalFilesProcessed":2,"filesWithErrors":1,"errorCount":1,"errorFiles":["C:\\Users\\PEARL\\Desktop\\uglify-js-minify-css-allfiles\\test\\test.js"]}}
|
|
73
|
+
[08/21/2024, 05:00:00] [INFO] Starting minification process {"contentPath":"./test/","excludeFolder":"lib","useBabel":{"targets":"chrome 40"}}
|
|
74
|
+
[08/21/2024, 05:00:00] [INFO] Writing file: C:\Users\PEARL\Desktop\uglify-js-minify-css-allfiles\test\test.css
|
|
75
|
+
[08/21/2024, 05:00:01] [INFO] Writing file: C:\Users\PEARL\Desktop\uglify-js-minify-css-allfiles\test\test.js
|
|
76
|
+
[08/21/2024, 05:00:01] [INFO] Processing Summary {"summary":{"totalFilesProcessed":2,"filesWithErrors":0,"errorCount":0,"errorFiles":[]}}
|
|
77
|
+
[08/21/2024, 12:02:11] [INFO] Starting minification process {"contentPath":"./test/","excludeFolder":"lib","useBabel":{"targets":"chrome 40"}}
|
|
78
|
+
[08/21/2024, 12:02:11] [INFO] Writing file: C:\Users\PEARL\Desktop\uglify-js-minify-css-allfiles\test\test.css
|
|
79
|
+
[08/21/2024, 12:02:12] [INFO] Writing file: C:\Users\PEARL\Desktop\uglify-js-minify-css-allfiles\test\test.js
|
|
80
|
+
[08/21/2024, 12:02:12] [INFO] Processing Summary {"summary":{"totalFilesProcessed":2,"filesWithErrors":0,"errorCount":0,"errorFiles":[]}}
|
package/minify.d.ts
CHANGED
|
@@ -1,31 +1,135 @@
|
|
|
1
1
|
declare module 'uglify-js-minify-css-allfiles' {
|
|
2
|
+
/**
|
|
3
|
+
* Babel configuration options.
|
|
4
|
+
* These options are passed directly to @babel/preset-env.
|
|
5
|
+
*/
|
|
2
6
|
export interface BabelOptions {
|
|
7
|
+
/**
|
|
8
|
+
* Describes the environments you support/target for your project.
|
|
9
|
+
* Can be a string (e.g., "last 2 versions", "safari >= 7"), an array of strings, or an object of minimum environment versions to support.
|
|
10
|
+
*/
|
|
3
11
|
targets?: string | string[] | { [key: string]: string };
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* Enables transformation of ES6 module syntax to another module type.
|
|
15
|
+
* Use false to preserve ES modules.
|
|
16
|
+
*/
|
|
4
17
|
modules?: 'amd' | 'umd' | 'systemjs' | 'commonjs' | 'cjs' | 'auto' | false;
|
|
18
|
+
|
|
19
|
+
/** Enable debug output to see what Babel is doing. */
|
|
5
20
|
debug?: boolean;
|
|
21
|
+
|
|
22
|
+
/** Array of plugins to always include. */
|
|
6
23
|
include?: string[];
|
|
24
|
+
|
|
25
|
+
/** Array of plugins to always exclude/remove. */
|
|
7
26
|
exclude?: string[];
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* Configures how Babel handles polyfills.
|
|
30
|
+
* 'usage' adds specific imports for polyfills when they are used in each file.
|
|
31
|
+
* 'entry' imports the full polyfill based on your target environments.
|
|
32
|
+
*/
|
|
8
33
|
useBuiltIns?: 'usage' | 'entry' | false;
|
|
34
|
+
|
|
35
|
+
/**
|
|
36
|
+
* Specifies the core-js version used when useBuiltIns is set to 'usage' or 'entry'.
|
|
37
|
+
*/
|
|
9
38
|
corejs?: 2 | 3 | { version: 2 | 3; proposals: boolean };
|
|
39
|
+
|
|
40
|
+
/**
|
|
41
|
+
* Forces Babel to apply all transformations, even if the target environment(s) support them natively.
|
|
42
|
+
*/
|
|
10
43
|
forceAllTransforms?: boolean;
|
|
44
|
+
|
|
45
|
+
/**
|
|
46
|
+
* Path to a .browserslistrc file to use instead of targets.
|
|
47
|
+
*/
|
|
11
48
|
configPath?: string;
|
|
49
|
+
|
|
50
|
+
/**
|
|
51
|
+
* Toggles whether or not browserslist config sources are used, which includes searching for any browserslist files or referencing the browserslist key inside package.json.
|
|
52
|
+
*/
|
|
12
53
|
ignoreBrowserslistConfig?: boolean;
|
|
54
|
+
|
|
55
|
+
/**
|
|
56
|
+
* Toggles enabling support for builtin/feature proposals that have shipped in browsers.
|
|
57
|
+
*/
|
|
13
58
|
shippedProposals?: boolean;
|
|
14
59
|
}
|
|
15
60
|
|
|
61
|
+
/**
|
|
62
|
+
* Logging configuration options.
|
|
63
|
+
*/
|
|
16
64
|
export interface LogOptions {
|
|
65
|
+
/**
|
|
66
|
+
* Specifies the directory where log files will be stored.
|
|
67
|
+
* @default 'logs'
|
|
68
|
+
*/
|
|
17
69
|
logDir?: string;
|
|
70
|
+
|
|
71
|
+
/**
|
|
72
|
+
* Number of days to keep log files before they are deleted.
|
|
73
|
+
* @default 30
|
|
74
|
+
*/
|
|
18
75
|
retentionDays?: number;
|
|
19
|
-
|
|
76
|
+
|
|
77
|
+
/**
|
|
78
|
+
* Sets the minimum level of messages that will be logged.
|
|
79
|
+
* @default 'info'
|
|
80
|
+
*/
|
|
81
|
+
logLevel?: 'error' | 'warn' | 'info' | 'debug';
|
|
82
|
+
|
|
83
|
+
/**
|
|
84
|
+
* Format for dates in log file names and entries.
|
|
85
|
+
* @default 'YYYY-MM-DD'
|
|
86
|
+
*/
|
|
20
87
|
dateFormat?: string;
|
|
88
|
+
|
|
89
|
+
/**
|
|
90
|
+
* Time zone used for timestamps in log entries.
|
|
91
|
+
* @default 'UTC'
|
|
92
|
+
*/
|
|
21
93
|
timeZone?: string;
|
|
94
|
+
|
|
95
|
+
/**
|
|
96
|
+
* Whether to output logs to the console in addition to (or instead of) writing to files.
|
|
97
|
+
* @default true
|
|
98
|
+
*/
|
|
22
99
|
logToConsole?: boolean;
|
|
100
|
+
|
|
101
|
+
/**
|
|
102
|
+
* Whether to write logs to files.
|
|
103
|
+
* @default true
|
|
104
|
+
*/
|
|
23
105
|
logToFile?: boolean;
|
|
24
106
|
}
|
|
25
107
|
|
|
108
|
+
/**
|
|
109
|
+
* Configuration options for the minifyAll function.
|
|
110
|
+
*/
|
|
26
111
|
export interface MinifyOptions {
|
|
112
|
+
/**
|
|
113
|
+
* Name of a folder to exclude from the minification process.
|
|
114
|
+
* Useful for skipping already minified files or third-party libraries.
|
|
115
|
+
* @default ''
|
|
116
|
+
*/
|
|
27
117
|
excludeFolder?: string;
|
|
118
|
+
|
|
119
|
+
/**
|
|
120
|
+
* Enables Babel transformation of JavaScript files.
|
|
121
|
+
* If true, uses default Babel settings.
|
|
122
|
+
* If an object is provided, it should conform to the BabelOptions interface.
|
|
123
|
+
* @default false
|
|
124
|
+
*/
|
|
28
125
|
useBabel?: boolean | BabelOptions;
|
|
126
|
+
|
|
127
|
+
/**
|
|
128
|
+
* Configures logging behavior.
|
|
129
|
+
* If true, uses default logging settings.
|
|
130
|
+
* If an object is provided, it should conform to the LogOptions interface.
|
|
131
|
+
* @default true
|
|
132
|
+
*/
|
|
29
133
|
useLog?: boolean | LogOptions;
|
|
30
134
|
}
|
|
31
135
|
|
|
@@ -33,9 +137,29 @@ declare module 'uglify-js-minify-css-allfiles' {
|
|
|
33
137
|
* Minifies all JavaScript and CSS files in the specified directory and its subdirectories.
|
|
34
138
|
*
|
|
35
139
|
* @param contentPath - The path to the directory containing the files to be minified.
|
|
36
|
-
*
|
|
140
|
+
* This is the root directory from which the function will start searching for files.
|
|
141
|
+
* @param options - Configuration options for the minification process.
|
|
142
|
+
* These options control Babel usage, logging, and allow excluding certain folders.
|
|
37
143
|
* @returns A promise that resolves when all files have been processed.
|
|
38
|
-
* @throws {Error} If there's an issue reading or writing files.
|
|
144
|
+
* @throws {Error} If there's an issue reading or writing files, or if the minification process fails.
|
|
145
|
+
*
|
|
146
|
+
* @example
|
|
147
|
+
* ```typescript
|
|
148
|
+
* import minifyAll from 'uglify-js-minify-css-allfiles';
|
|
149
|
+
*
|
|
150
|
+
* await minifyAll('./src', {
|
|
151
|
+
* excludeFolder: 'node_modules',
|
|
152
|
+
* useBabel: {
|
|
153
|
+
* targets: '> 0.25%, not dead',
|
|
154
|
+
* useBuiltIns: 'usage',
|
|
155
|
+
* corejs: 3
|
|
156
|
+
* },
|
|
157
|
+
* useLog: {
|
|
158
|
+
* logLevel: 'warn',
|
|
159
|
+
* retentionDays: 7
|
|
160
|
+
* }
|
|
161
|
+
* });
|
|
162
|
+
* ```
|
|
39
163
|
*/
|
|
40
164
|
export default function minifyAll(contentPath: string, options?: MinifyOptions): Promise<void>;
|
|
41
165
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "uglify-js-minify-css-allfiles",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.2.0",
|
|
4
4
|
"description": "you will be able to minify all files as same file names which is js or css",
|
|
5
5
|
"main": "minify.js",
|
|
6
6
|
"type": "module",
|
|
@@ -15,6 +15,9 @@
|
|
|
15
15
|
"type": "git",
|
|
16
16
|
"url": "git+https://github.com/oinochoe/uglify-js-minify-css-allfiles.git"
|
|
17
17
|
},
|
|
18
|
+
"publishConfig": {
|
|
19
|
+
"registry": "https://registry.npmjs.org/"
|
|
20
|
+
},
|
|
18
21
|
"keywords": [
|
|
19
22
|
"ugly-code",
|
|
20
23
|
"uglyCode",
|