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.
- package/CHANGELOG.md +39 -0
- package/README.md +214 -127
- package/demo.js +3 -0
- package/dist/module.js +199 -95
- package/dist/modules/fileHandler.js +21 -10
- package/dist/modules/hashManager.js +114 -0
- package/dist/modules/imageUtils.js +63 -0
- package/dist/modules/logger.js +4 -6
- package/dist/modules/minifier.js +6 -8
- package/dist/modules/pathResolver.js +100 -0
- package/logs/log-02-10-2025.log +12 -0
- package/logs/log-02-11-2025.log +1094 -0
- package/logs/log-02-13-2025.log +222 -0
- package/package.json +1 -1
- package/test/img/sample.jpg +0 -0
- package/test/img/samples.svg +10 -0
- package/test/test.css +72 -6
- package/test/test.js +9 -2
- package/logs/log-08-20-2024.log +0 -65
- package/logs/log-08-21-2024.log +0 -80
- package/logs/log-08-22-2024.log +0 -8
package/CHANGELOG.md
CHANGED
|
@@ -5,6 +5,45 @@ 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.3.0] - 2025-02-13
|
|
9
|
+
|
|
10
|
+
### Added
|
|
11
|
+
|
|
12
|
+
- Image versioning system with content-based hashing for cache busting
|
|
13
|
+
- Support for multiple image formats (PNG, JPEG, GIF, SVG, WebP, etc.)
|
|
14
|
+
- Automatic hash generation for images in CSS files
|
|
15
|
+
- Random hash generation for JS image references
|
|
16
|
+
- Support for various image path formats including absolute, relative, data URIs
|
|
17
|
+
- Complex CSS background and image-set() syntax support
|
|
18
|
+
- New `useVersioning` option with configurable file extensions
|
|
19
|
+
- Hash management system for tracking and updating image versions
|
|
20
|
+
- Comprehensive image path resolution and processing utilities
|
|
21
|
+
|
|
22
|
+
### Changed
|
|
23
|
+
|
|
24
|
+
- Enhanced documentation with detailed image versioning examples and configuration options
|
|
25
|
+
- Improved path resolution system to handle various image reference formats
|
|
26
|
+
- Updated logging system to track image versioning operations
|
|
27
|
+
|
|
28
|
+
## [2.2.4] - 2024-08-23
|
|
29
|
+
|
|
30
|
+
### Changed
|
|
31
|
+
|
|
32
|
+
- Updated `resolveBabelOptions` function to dynamically import `@babel/preset-env` using `resolveModulePath`
|
|
33
|
+
- Modified `minifyAll` function to handle the new asynchronous `resolveBabelOptions`
|
|
34
|
+
|
|
35
|
+
### Improved
|
|
36
|
+
|
|
37
|
+
- Enhanced flexibility in loading Babel presets, allowing for better compatibility with different environments
|
|
38
|
+
|
|
39
|
+
## [2.2.3] - 2024-08-23
|
|
40
|
+
|
|
41
|
+
### Improved
|
|
42
|
+
|
|
43
|
+
- Enhanced type definitions using JSDoc comments for better IDE support and code documentation
|
|
44
|
+
- Added more specific type definitions for JSMinifyOptions and CSSMinifyOptions
|
|
45
|
+
- Improved type annotations for function parameters and return types
|
|
46
|
+
|
|
8
47
|
## [2.2.2] - 2024-08-22
|
|
9
48
|
|
|
10
49
|
### Fixed
|
package/README.md
CHANGED
|
@@ -1,36 +1,39 @@
|
|
|
1
|
-
[![NPM downloads][npm-downloads]][npm-url]
|
|
2
|
-
[![NPM total downloads][npm-total-downloads]][npm-url]
|
|
3
|
-
|
|
4
|
-
| <br>[![Donate][donate-badge]][donate-url] <br> | Your help is appreciated! [Create a PR][create-pr] or just [buy me a coffee][donate-url] |
|
|
5
|
-
| ---------------------------------------------------------- | ---------------------------------------------------------------------------------------- |
|
|
6
|
-
|
|
7
|
-
[npm-url]: https://www.npmjs.com/package/uglify-js-minify-css-allfiles
|
|
8
|
-
[npm-downloads]: https://img.shields.io/npm/dm/uglify-js-minify-css-allfiles.svg
|
|
9
|
-
[npm-total-downloads]: https://img.shields.io/npm/dt/uglify-js-minify-css-allfiles.svg?label=total+downloads
|
|
10
|
-
[donate-badge]: https://img.shields.io/badge/Buy%20me%20a%20coffee-Donate-red.svg
|
|
11
|
-
[donate-url]: https://github.com/sponsors/oinochoe
|
|
12
|
-
[create-pr]: https://github.com/oinochoe/uglify-js-minify-css-allfiles/pulls
|
|
13
|
-
|
|
14
1
|
# uglify-js-minify-css-allfiles
|
|
15
2
|
|
|
16
3
|
A powerful tool to minify and obfuscate JavaScript and CSS files in your project.
|
|
17
4
|
It helps protect your code in deployment environments and makes it less recognizable to others, all through a simple CLI interface.
|
|
18
5
|
You can easily minify all files in a specific folder, with the option to exclude certain directories.
|
|
19
6
|
|
|
7
|
+
[![NPM downloads][npm-downloads]][npm-url]
|
|
8
|
+
[![NPM total downloads][npm-total-downloads]][npm-url]
|
|
20
9
|
[](https://www.npmjs.com/package/uglify-js-minify-css-allfiles)
|
|
21
10
|
|
|
22
|
-
---
|
|
23
|
-
|
|
24
11
|
## Table of Contents
|
|
25
12
|
|
|
26
13
|
- [Installation](#installation)
|
|
14
|
+
- [Features](#features)
|
|
27
15
|
- [Usage](#usage)
|
|
28
16
|
- [Parameters](#parameters)
|
|
29
17
|
- [Options](#options)
|
|
18
|
+
- [Advanced Features](#advanced-features)
|
|
19
|
+
- [Babel Integration](#babel-integration)
|
|
20
|
+
- [Image Versioning](#image-versioning)
|
|
21
|
+
- [Logging System](#logging-system)
|
|
22
|
+
- [API Reference](#api-reference)
|
|
30
23
|
- [Minification Options](#minification-options)
|
|
31
|
-
- [
|
|
24
|
+
- [Contributing](#contributing)
|
|
32
25
|
- [License](#license)
|
|
33
26
|
|
|
27
|
+
## Features
|
|
28
|
+
|
|
29
|
+
- 🚀 JavaScript and CSS minification with advanced options
|
|
30
|
+
- 📦 Babel transformation support for modern JavaScript
|
|
31
|
+
- 🖼️ Automatic image versioning and cache busting
|
|
32
|
+
- 📝 Comprehensive logging system
|
|
33
|
+
- 🛡️ Configurable file exclusion
|
|
34
|
+
- 🔄 ES module support
|
|
35
|
+
- 📊 Processing statistics and summaries
|
|
36
|
+
|
|
34
37
|
## Installation
|
|
35
38
|
|
|
36
39
|
Install with `npm`:
|
|
@@ -41,136 +44,220 @@ $ npm i uglify-js-minify-css-allfiles
|
|
|
41
44
|
|
|
42
45
|
## Usage
|
|
43
46
|
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
```js
|
|
47
|
-
import minifyAll from 'uglify-js-minify-css-allfiles';
|
|
48
|
-
|
|
49
|
-
await minifyAll('./src/');
|
|
50
|
-
```
|
|
51
|
-
|
|
52
|
-
2. Using options:
|
|
53
|
-
|
|
54
|
-
```js
|
|
55
|
-
import minifyAll from 'uglify-js-minify-css-allfiles';
|
|
56
|
-
|
|
57
|
-
await minifyAll('./src/', {
|
|
58
|
-
excludeFolder: 'node_modules',
|
|
59
|
-
useBabel: {
|
|
60
|
-
targets: 'chrome 40',
|
|
61
|
-
modules: false,
|
|
62
|
-
useBuiltIns: 'usage',
|
|
63
|
-
corejs: 3,
|
|
64
|
-
},
|
|
65
|
-
useLog: {
|
|
66
|
-
logDir: 'logs',
|
|
67
|
-
retentionDays: 30,
|
|
68
|
-
logLevel: 'info',
|
|
69
|
-
dateFormat: 'YYYY-MM-DD',
|
|
70
|
-
timeZone: 'UTC',
|
|
71
|
-
logToConsole: true,
|
|
72
|
-
logToFile: true,
|
|
73
|
-
},
|
|
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,
|
|
95
|
-
},
|
|
96
|
-
});
|
|
97
|
-
```
|
|
98
|
-
|
|
99
|
-
## Parameters
|
|
100
|
-
|
|
101
|
-
The `minifyAll` function accepts the following parameters:
|
|
102
|
-
|
|
103
|
-
| Parameter | Type | Default | Description |
|
|
104
|
-
| ------------- | ------ | ------- | -------------------------------------------------------------------------------------------- |
|
|
105
|
-
| `contentPath` | string | - | The path to the directory containing the files to be minified. This is a required parameter. |
|
|
106
|
-
| `options` | object | `{}` | An object containing options for minification, Babel, and logging. |
|
|
107
|
-
|
|
108
|
-
## Options
|
|
109
|
-
|
|
110
|
-
The `options` object can have the following properties:
|
|
111
|
-
|
|
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). |
|
|
47
|
+
### Basic Usage
|
|
119
48
|
|
|
120
|
-
|
|
49
|
+
```js
|
|
50
|
+
import minifyAll from 'uglify-js-minify-css-allfiles';
|
|
121
51
|
|
|
122
|
-
|
|
52
|
+
await minifyAll('./src/');
|
|
53
|
+
```
|
|
123
54
|
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
55
|
+
### Advanced Usage
|
|
56
|
+
|
|
57
|
+
```js
|
|
58
|
+
import minifyAll from 'uglify-js-minify-css-allfiles';
|
|
59
|
+
|
|
60
|
+
await minifyAll('./src/', {
|
|
61
|
+
excludeFolder: 'node_modules',
|
|
62
|
+
useBabel: {
|
|
63
|
+
targets: 'chrome 40',
|
|
64
|
+
modules: false,
|
|
65
|
+
useBuiltIns: 'usage',
|
|
66
|
+
corejs: 3,
|
|
67
|
+
},
|
|
68
|
+
useLog: {
|
|
69
|
+
logDir: 'logs',
|
|
70
|
+
retentionDays: 30,
|
|
71
|
+
logLevel: 'info',
|
|
72
|
+
dateFormat: 'YYYY-MM-DD',
|
|
73
|
+
timeZone: 'UTC',
|
|
74
|
+
logToConsole: true,
|
|
75
|
+
logToFile: true,
|
|
76
|
+
},
|
|
77
|
+
jsMinifyOptions: {
|
|
78
|
+
compress: {
|
|
79
|
+
dead_code: true,
|
|
80
|
+
drop_debugger: true,
|
|
81
|
+
pure_funcs: ['console.log'],
|
|
82
|
+
conditionals: true,
|
|
83
|
+
evaluate: true,
|
|
84
|
+
unused: true,
|
|
85
|
+
},
|
|
86
|
+
mangle: true,
|
|
87
|
+
},
|
|
88
|
+
cssMinifyOptions: {
|
|
89
|
+
level: 2,
|
|
90
|
+
},
|
|
91
|
+
useVersioning: {
|
|
92
|
+
extensions: ['.png', '.jpg', '.jpeg', '.gif', '.svg', '.webp'],
|
|
93
|
+
},
|
|
94
|
+
});
|
|
95
|
+
```
|
|
131
96
|
|
|
132
|
-
|
|
97
|
+
## Advanced Features
|
|
133
98
|
|
|
134
|
-
|
|
99
|
+
### Babel Integration
|
|
135
100
|
|
|
136
|
-
|
|
137
|
-
| --------------- | ------- | -------------- | --------------------------------------------------------------------- |
|
|
138
|
-
| `logDir` | string | `'logs'` | Specifies the directory for log files. |
|
|
139
|
-
| `retentionDays` | number | 30 | Number of days to retain log files. |
|
|
140
|
-
| `logLevel` | string | `'info'` | Specifies the level of logging (e.g., `'info'`, `'warn'`, `'error'`). |
|
|
141
|
-
| `dateFormat` | string | `'YYYY-MM-DD'` | Format for the date in log entries. |
|
|
142
|
-
| `timeZone` | string | `'UTC'` | Time zone for timestamps in log entries. |
|
|
143
|
-
| `logToConsole` | boolean | `true` | Determines if logs should also be output to the console. |
|
|
144
|
-
| `logToFile` | boolean | `true` | Determines if logs should be written to a file. |
|
|
101
|
+
Built-in Babel support for modern JavaScript transpilation:
|
|
145
102
|
|
|
146
|
-
|
|
103
|
+
- Configurable target environments
|
|
104
|
+
- Module transformation options
|
|
105
|
+
- Built-ins and CoreJS integration
|
|
106
|
+
- Customizable plugin/preset options
|
|
147
107
|
|
|
148
|
-
|
|
108
|
+
```js
|
|
109
|
+
await minifyAll('./src/', {
|
|
110
|
+
useBabel: {
|
|
111
|
+
targets: 'chrome 40',
|
|
112
|
+
modules: false,
|
|
113
|
+
useBuiltIns: 'usage',
|
|
114
|
+
corejs: 3,
|
|
115
|
+
},
|
|
116
|
+
});
|
|
117
|
+
```
|
|
149
118
|
|
|
150
|
-
|
|
119
|
+
### Image Versioning
|
|
120
|
+
|
|
121
|
+
Automatic versioning for image references in JS and CSS files:
|
|
122
|
+
|
|
123
|
+
- Content-based hashing for images in CSS files
|
|
124
|
+
- Random hash generation for JS image references
|
|
125
|
+
- Support for multiple image formats (PNG, JPEG, GIF, SVG, WebP, etc.)
|
|
126
|
+
- Handles various image path formats:
|
|
127
|
+
- Absolute and relative paths
|
|
128
|
+
- Data URIs
|
|
129
|
+
- HTTP/HTTPS URLs
|
|
130
|
+
- Complex CSS background declarations
|
|
131
|
+
- image-set() syntax support
|
|
132
|
+
|
|
133
|
+
```js
|
|
134
|
+
await minifyAll('./src/', {
|
|
135
|
+
useVersioning: {
|
|
136
|
+
extensions: ['.png', '.jpg', '.jpeg', '.gif', '.svg', '.webp'],
|
|
137
|
+
},
|
|
138
|
+
});
|
|
139
|
+
```
|
|
151
140
|
|
|
152
|
-
|
|
141
|
+
### Logging System
|
|
142
|
+
|
|
143
|
+
Comprehensive logging capabilities:
|
|
144
|
+
|
|
145
|
+
- Multiple log levels (error, warn, info, debug)
|
|
146
|
+
- File rotation with retention policies
|
|
147
|
+
- Customizable date formats and timezones
|
|
148
|
+
- Console and file output options
|
|
149
|
+
- Processing statistics and summaries
|
|
150
|
+
|
|
151
|
+
```js
|
|
152
|
+
await minifyAll('./src/', {
|
|
153
|
+
useLog: {
|
|
154
|
+
logDir: 'logs',
|
|
155
|
+
retentionDays: 30,
|
|
156
|
+
logLevel: 'info',
|
|
157
|
+
dateFormat: 'YYYY-MM-DD',
|
|
158
|
+
timeZone: 'UTC',
|
|
159
|
+
logToConsole: true,
|
|
160
|
+
logToFile: true,
|
|
161
|
+
},
|
|
162
|
+
});
|
|
163
|
+
```
|
|
153
164
|
|
|
154
|
-
|
|
155
|
-
- `mangle`: Controls name mangling. Can be a boolean or an object with more specific options.
|
|
156
|
-
- `output`: An object controlling the output format.
|
|
165
|
+
## API Reference
|
|
157
166
|
|
|
158
|
-
###
|
|
167
|
+
### minifyAll(contentPath, options)
|
|
168
|
+
|
|
169
|
+
Main function to process files.
|
|
170
|
+
|
|
171
|
+
- `contentPath` (string): Source directory path
|
|
172
|
+
- `options` (object): Configuration options
|
|
173
|
+
- `excludeFolder` (string): Directory to exclude
|
|
174
|
+
- `useBabel` (boolean|object): Babel configuration
|
|
175
|
+
- `useLog` (boolean|object): Logging configuration
|
|
176
|
+
- `jsMinifyOptions` (object): JavaScript minification options
|
|
177
|
+
- `cssMinifyOptions` (object): CSS minification options
|
|
178
|
+
- `useVersioning` (object): Image versioning configuration
|
|
179
|
+
- `extensions` (string[]): List of image extensions to version
|
|
159
180
|
|
|
160
|
-
|
|
181
|
+
### Babel Options
|
|
182
|
+
|
|
183
|
+
The `useBabel` object supports all @babel/preset-env options:
|
|
184
|
+
|
|
185
|
+
```js
|
|
186
|
+
{
|
|
187
|
+
targets: string | string[] | Object,
|
|
188
|
+
modules: 'amd' | 'umd' | 'systemjs' | 'commonjs' | false,
|
|
189
|
+
debug: boolean,
|
|
190
|
+
include: string[],
|
|
191
|
+
exclude: string[],
|
|
192
|
+
useBuiltIns: 'usage' | 'entry' | false,
|
|
193
|
+
corejs: 2 | 3 | { version: 2 | 3, proposals: boolean },
|
|
194
|
+
forceAllTransforms: boolean,
|
|
195
|
+
configPath: string,
|
|
196
|
+
ignoreBrowserslistConfig: boolean,
|
|
197
|
+
shippedProposals: boolean
|
|
198
|
+
}
|
|
199
|
+
```
|
|
200
|
+
|
|
201
|
+
### JavaScript Minification Options
|
|
161
202
|
|
|
162
|
-
|
|
203
|
+
Supports all UglifyJS options:
|
|
204
|
+
|
|
205
|
+
```js
|
|
206
|
+
{
|
|
207
|
+
compress: {
|
|
208
|
+
dead_code: boolean,
|
|
209
|
+
drop_debugger: boolean,
|
|
210
|
+
pure_funcs: string[],
|
|
211
|
+
conditionals: boolean,
|
|
212
|
+
evaluate: boolean,
|
|
213
|
+
booleans: boolean,
|
|
214
|
+
loops: boolean,
|
|
215
|
+
unused: boolean,
|
|
216
|
+
if_return: boolean,
|
|
217
|
+
join_vars: boolean,
|
|
218
|
+
cascade: boolean,
|
|
219
|
+
side_effects: boolean
|
|
220
|
+
},
|
|
221
|
+
mangle: boolean | Object,
|
|
222
|
+
output: {
|
|
223
|
+
beautify: boolean,
|
|
224
|
+
comments: boolean | 'all' | 'some' | RegExp
|
|
225
|
+
}
|
|
226
|
+
}
|
|
227
|
+
```
|
|
163
228
|
|
|
164
|
-
|
|
165
|
-
- `compatibility`: Browser compatibility (e.g., 'ie7', '\*').
|
|
166
|
-
- `format`: Output formatting options.
|
|
229
|
+
### CSS Minification Options
|
|
167
230
|
|
|
168
|
-
|
|
231
|
+
Supports Clean-CSS options:
|
|
232
|
+
|
|
233
|
+
```js
|
|
234
|
+
{
|
|
235
|
+
level: 0 | 1 | 2 | {
|
|
236
|
+
1: {
|
|
237
|
+
all: boolean,
|
|
238
|
+
specialComments: boolean | string
|
|
239
|
+
},
|
|
240
|
+
2: {
|
|
241
|
+
mergeSemantically: boolean,
|
|
242
|
+
restructureRules: boolean
|
|
243
|
+
}
|
|
244
|
+
},
|
|
245
|
+
compatibility: string | string[],
|
|
246
|
+
format: string | Object
|
|
247
|
+
}
|
|
248
|
+
```
|
|
169
249
|
|
|
170
|
-
|
|
250
|
+
## Contributing
|
|
171
251
|
|
|
172
|
-
[
|
|
252
|
+
Your help is appreciated! [Create a PR][create-pr] or just [buy me a coffee][donate-url]
|
|
173
253
|
|
|
174
254
|
## License
|
|
175
255
|
|
|
176
256
|
MIT. See [LICENSE.md](https://github.com/oinochoe/uglify-js-minify-css-allfiles/blob/master/LICENSE) for details.
|
|
257
|
+
|
|
258
|
+
[npm-url]: https://www.npmjs.com/package/uglify-js-minify-css-allfiles
|
|
259
|
+
[npm-downloads]: https://img.shields.io/npm/dm/uglify-js-minify-css-allfiles.svg
|
|
260
|
+
[npm-total-downloads]: https://img.shields.io/npm/dt/uglify-js-minify-css-allfiles.svg?label=total+downloads
|
|
261
|
+
[donate-badge]: https://img.shields.io/badge/Buy%20me%20a%20coffee-Donate-red.svg
|
|
262
|
+
[donate-url]: https://github.com/sponsors/oinochoe
|
|
263
|
+
[create-pr]: https://github.com/oinochoe/uglify-js-minify-css-allfiles/pulls
|