uglify-js-minify-css-allfiles 2.7.0 → 2.8.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/README.md +45 -5
- package/demo.js +4 -0
- package/dist/module.js +2 -2
- package/dist/modules/postcssProcess.js +6 -3
- package/minify.d.ts +69 -3
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -13,8 +13,6 @@ You can easily minify all files in a specific folder, with the option to exclude
|
|
|
13
13
|
- [Installation](#installation)
|
|
14
14
|
- [Features](#features)
|
|
15
15
|
- [Usage](#usage)
|
|
16
|
-
- [Parameters](#parameters)
|
|
17
|
-
- [Options](#options)
|
|
18
16
|
- [Advanced Features](#advanced-features)
|
|
19
17
|
- [Babel Integration](#babel-integration)
|
|
20
18
|
- [PostCSS Processing](#postcss-processing)
|
|
@@ -22,7 +20,6 @@ You can easily minify all files in a specific folder, with the option to exclude
|
|
|
22
20
|
- [Logging System](#logging-system)
|
|
23
21
|
- [Source Maps](#source-maps)
|
|
24
22
|
- [API Reference](#api-reference)
|
|
25
|
-
- [Minification Options](#minification-options)
|
|
26
23
|
- [Contributing](#contributing)
|
|
27
24
|
- [License](#license)
|
|
28
25
|
|
|
@@ -60,6 +57,8 @@ await minifyAll('./src/');
|
|
|
60
57
|
|
|
61
58
|
```js
|
|
62
59
|
import minifyAll from 'uglify-js-minify-css-allfiles';
|
|
60
|
+
import postcssImport from 'postcss-import';
|
|
61
|
+
import postcssMixins from 'postcss-mixins';
|
|
63
62
|
|
|
64
63
|
await minifyAll('./src/', {
|
|
65
64
|
excludeFolder: 'node_modules',
|
|
@@ -82,6 +81,10 @@ await minifyAll('./src/', {
|
|
|
82
81
|
autoprefixer: {
|
|
83
82
|
grid: true,
|
|
84
83
|
},
|
|
84
|
+
plugins: [
|
|
85
|
+
postcssImport(),
|
|
86
|
+
postcssMixins(),
|
|
87
|
+
],
|
|
85
88
|
},
|
|
86
89
|
useLog: {
|
|
87
90
|
logDir: 'logs',
|
|
@@ -144,6 +147,7 @@ Process modern CSS features with PostCSS integration:
|
|
|
144
147
|
- Automatically transpile modern CSS to be compatible with older browsers
|
|
145
148
|
- Support for customizable browser targets
|
|
146
149
|
- Integrated with the CSS minification pipeline
|
|
150
|
+
- **Extensible with any PostCSS plugin**
|
|
147
151
|
|
|
148
152
|
```js
|
|
149
153
|
await minifyAll('./src/', {
|
|
@@ -162,6 +166,32 @@ await minifyAll('./src/', {
|
|
|
162
166
|
});
|
|
163
167
|
```
|
|
164
168
|
|
|
169
|
+
#### PostCSS Custom Plugins
|
|
170
|
+
|
|
171
|
+
You can extend the PostCSS pipeline with any additional plugins via the `plugins` option.
|
|
172
|
+
Custom plugins are appended **after** `postcss-preset-env`, so they receive the already-transformed CSS.
|
|
173
|
+
|
|
174
|
+
```js
|
|
175
|
+
import postcssImport from 'postcss-import';
|
|
176
|
+
import postcssMixins from 'postcss-mixins';
|
|
177
|
+
import postcssCustomMedia from 'postcss-custom-media';
|
|
178
|
+
|
|
179
|
+
await minifyAll('./src/', {
|
|
180
|
+
usePostCSS: {
|
|
181
|
+
browsers: ['Chrome >= 40'],
|
|
182
|
+
stage: 2,
|
|
183
|
+
plugins: [
|
|
184
|
+
postcssImport(), // Resolve @import rules
|
|
185
|
+
postcssMixins(), // Enable CSS mixins
|
|
186
|
+
postcssCustomMedia(), // Enable @custom-media queries
|
|
187
|
+
],
|
|
188
|
+
},
|
|
189
|
+
});
|
|
190
|
+
```
|
|
191
|
+
|
|
192
|
+
> **Note:** Each plugin must be a PostCSS-compatible plugin instance or factory function.
|
|
193
|
+
> Install any extra plugins separately (e.g. `npm i postcss-import`).
|
|
194
|
+
|
|
165
195
|
### CSS Example with PostCSS Features
|
|
166
196
|
|
|
167
197
|
```css
|
|
@@ -249,6 +279,7 @@ await minifyAll('./src/', {
|
|
|
249
279
|
useJsMap: true,
|
|
250
280
|
useCssMap: true
|
|
251
281
|
});
|
|
282
|
+
```
|
|
252
283
|
|
|
253
284
|
## API Reference
|
|
254
285
|
|
|
@@ -261,6 +292,7 @@ Main function to process files.
|
|
|
261
292
|
- `excludeFolder` (string): Directory to exclude
|
|
262
293
|
- `useBabel` (boolean|object): Babel configuration
|
|
263
294
|
- `usePostCSS` (boolean|object): PostCSS configuration
|
|
295
|
+
- `plugins` (Array): Additional PostCSS plugins (appended after `postcss-preset-env`)
|
|
264
296
|
- `useLog` (boolean|object): Logging configuration
|
|
265
297
|
- `jsMinifyOptions` (object): JavaScript minification options
|
|
266
298
|
- `cssMinifyOptions` (object): CSS minification options
|
|
@@ -287,7 +319,7 @@ The `useBabel` object supports all @babel/preset-env options:
|
|
|
287
319
|
ignoreBrowserslistConfig: boolean,
|
|
288
320
|
shippedProposals: boolean,
|
|
289
321
|
useAppendTransform: boolean,
|
|
290
|
-
plugins: Array<string|
|
|
322
|
+
plugins: Array<string|any[]|Function>
|
|
291
323
|
}
|
|
292
324
|
```
|
|
293
325
|
|
|
@@ -309,10 +341,18 @@ The `usePostCSS` object supports the following options:
|
|
|
309
341
|
grid: boolean | 'autoplace' | 'no-autoplace'
|
|
310
342
|
// Other autoprefixer options...
|
|
311
343
|
},
|
|
312
|
-
plugins: Array // Additional PostCSS plugins
|
|
344
|
+
plugins: Array<PostCSSPlugin> // Additional PostCSS plugins (appended after postcss-preset-env)
|
|
313
345
|
}
|
|
314
346
|
```
|
|
315
347
|
|
|
348
|
+
| Option | Type | Default | Description |
|
|
349
|
+
|--------|------|---------|-------------|
|
|
350
|
+
| `browsers` | `string[] \| Object` | `['Chrome >= 40']` | Browser targets passed to postcss-preset-env |
|
|
351
|
+
| `stage` | `0–5` | `2` | CSS feature stage level |
|
|
352
|
+
| `features` | `Object` | see defaults | Granular feature toggles |
|
|
353
|
+
| `autoprefixer` | `Object` | `{ grid: true }` | Autoprefixer options |
|
|
354
|
+
| `plugins` | `Array` | `[]` | Additional PostCSS plugins, appended after `postcss-preset-env` |
|
|
355
|
+
|
|
316
356
|
### JavaScript Minification Options
|
|
317
357
|
|
|
318
358
|
Supports all UglifyJS options:
|
package/demo.js
CHANGED
|
@@ -13,6 +13,10 @@ minifyAll('./test/', {
|
|
|
13
13
|
autoprefixer: {
|
|
14
14
|
grid: true,
|
|
15
15
|
},
|
|
16
|
+
// Add any PostCSS-compatible plugins here.
|
|
17
|
+
// Each plugin is appended after postcss-preset-env in the processing pipeline.
|
|
18
|
+
// Example: plugins: [postcssImport(), postcssMixins()]
|
|
19
|
+
plugins: [],
|
|
16
20
|
},
|
|
17
21
|
useBabel: {
|
|
18
22
|
targets: 'chrome 40',
|
package/dist/module.js
CHANGED
|
@@ -310,7 +310,7 @@ async function processFile(filePath, logger, options) {
|
|
|
310
310
|
* @property {boolean} [ignoreBrowserslistConfig] - Ignores the browserslist configuration.
|
|
311
311
|
* @property {boolean} [shippedProposals] - Enables support for shipped proposals.
|
|
312
312
|
* @property {boolean} [useAppendTransform] - Enables the append-to-appendChild transform plugin for compatibility with older browsers.
|
|
313
|
-
* @property {Array<string|
|
|
313
|
+
* @property {Array<string|any[]|Function>} [plugins] - Additional Babel plugins to include in the transformation process.
|
|
314
314
|
*/
|
|
315
315
|
|
|
316
316
|
/**
|
|
@@ -360,7 +360,7 @@ async function processFile(filePath, logger, options) {
|
|
|
360
360
|
* @property {JSMinifyOptions} [jsMinifyOptions={}] - Options for JavaScript minification.
|
|
361
361
|
* @property {CSSMinifyOptions} [cssMinifyOptions={}] - Options for CSS minification.
|
|
362
362
|
* @property {PostCSSOptions|boolean} [usePostCSS=false] - PostCSS configuration options.
|
|
363
|
-
* @property {string[]|null} [useVersioning=null] - Options for file versioning.
|
|
363
|
+
* @property {{extensions?: string[]}|null} [useVersioning=null] - Options for file versioning.
|
|
364
364
|
* @property {boolean} [useJsMap=false] - Whether to use JavaScript Map file.
|
|
365
365
|
* @property {boolean} [useCssMap=false] - Whether to use CSS Map file.
|
|
366
366
|
*/
|
|
@@ -34,18 +34,21 @@ const DEFAULT_OPTIONS = {
|
|
|
34
34
|
*/
|
|
35
35
|
export async function processWithPostCSS(content, filePath = '', options = {}) {
|
|
36
36
|
try {
|
|
37
|
+
// Separate custom plugins from preset-env options
|
|
38
|
+
const { plugins: customPlugins, ...presetEnvInput } = options;
|
|
39
|
+
|
|
37
40
|
// Merge options with defaults
|
|
38
41
|
const presetEnvOptions = {
|
|
39
42
|
...DEFAULT_OPTIONS,
|
|
40
|
-
...
|
|
43
|
+
...presetEnvInput,
|
|
41
44
|
};
|
|
42
45
|
|
|
43
46
|
// Configure plugins
|
|
44
47
|
const plugins = [postcssPresetEnv(presetEnvOptions)];
|
|
45
48
|
|
|
46
49
|
// Add any custom plugins from options
|
|
47
|
-
if (
|
|
48
|
-
plugins.push(...
|
|
50
|
+
if (customPlugins && Array.isArray(customPlugins)) {
|
|
51
|
+
plugins.push(...customPlugins);
|
|
49
52
|
}
|
|
50
53
|
|
|
51
54
|
// Process the CSS
|
package/minify.d.ts
CHANGED
|
@@ -66,7 +66,43 @@ declare module 'uglify-js-minify-css-allfiles' {
|
|
|
66
66
|
/**
|
|
67
67
|
* Additional Babel plugins to include in the transformation process.
|
|
68
68
|
*/
|
|
69
|
-
plugins?: Array<string |
|
|
69
|
+
plugins?: Array<string | any[] | Function>;
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
/**
|
|
73
|
+
* Configuration options for PostCSS processing.
|
|
74
|
+
*/
|
|
75
|
+
export interface PostCSSOptions {
|
|
76
|
+
/**
|
|
77
|
+
* Target browsers for the CSS compatibility.
|
|
78
|
+
* Can be an array of browser strings or a browserslist configuration object.
|
|
79
|
+
*/
|
|
80
|
+
browsers?: string[] | { [key: string]: any };
|
|
81
|
+
|
|
82
|
+
/**
|
|
83
|
+
* CSS features stage level.
|
|
84
|
+
* @default 2
|
|
85
|
+
*/
|
|
86
|
+
stage?: 0 | 1 | 2 | 3 | 4 | 5;
|
|
87
|
+
|
|
88
|
+
/**
|
|
89
|
+
* Specific CSS features to enable/disable.
|
|
90
|
+
*/
|
|
91
|
+
features?: {
|
|
92
|
+
[key: string]: boolean;
|
|
93
|
+
};
|
|
94
|
+
|
|
95
|
+
/**
|
|
96
|
+
* Autoprefixer options.
|
|
97
|
+
*/
|
|
98
|
+
autoprefixer?: {
|
|
99
|
+
[key: string]: any;
|
|
100
|
+
};
|
|
101
|
+
|
|
102
|
+
/**
|
|
103
|
+
* Additional PostCSS plugins to use.
|
|
104
|
+
*/
|
|
105
|
+
plugins?: Array<any>;
|
|
70
106
|
}
|
|
71
107
|
|
|
72
108
|
/**
|
|
@@ -172,6 +208,14 @@ declare module 'uglify-js-minify-css-allfiles' {
|
|
|
172
208
|
*/
|
|
173
209
|
useBabel?: boolean | BabelOptions;
|
|
174
210
|
|
|
211
|
+
/**
|
|
212
|
+
* Enables PostCSS processing of CSS files.
|
|
213
|
+
* If true, uses default PostCSS settings.
|
|
214
|
+
* If an object is provided, it should conform to the PostCSSOptions interface.
|
|
215
|
+
* @default false
|
|
216
|
+
*/
|
|
217
|
+
usePostCSS?: boolean | PostCSSOptions;
|
|
218
|
+
|
|
175
219
|
/**
|
|
176
220
|
* Configures logging behavior.
|
|
177
221
|
* If true, uses default logging settings.
|
|
@@ -192,6 +236,15 @@ declare module 'uglify-js-minify-css-allfiles' {
|
|
|
192
236
|
*/
|
|
193
237
|
cssMinifyOptions?: CSSMinifyOptions;
|
|
194
238
|
|
|
239
|
+
/**
|
|
240
|
+
* Enables automatic image versioning (cache busting) for image references in JS and CSS files.
|
|
241
|
+
* Content-based hashing is used for CSS images; random hashes are used for JS image references.
|
|
242
|
+
*/
|
|
243
|
+
useVersioning?: {
|
|
244
|
+
/** List of image file extensions to version (e.g. ['.png', '.jpg', '.svg']). */
|
|
245
|
+
extensions?: string[];
|
|
246
|
+
};
|
|
247
|
+
|
|
195
248
|
/**
|
|
196
249
|
* Enables source map generation for JavaScript files during minification.
|
|
197
250
|
* Source maps help with debugging by mapping minified code back to original source code.
|
|
@@ -228,12 +281,25 @@ declare module 'uglify-js-minify-css-allfiles' {
|
|
|
228
281
|
* useBuiltIns: 'usage',
|
|
229
282
|
* corejs: 3
|
|
230
283
|
* },
|
|
284
|
+
* usePostCSS: {
|
|
285
|
+
* browsers: ['Chrome >= 40'],
|
|
286
|
+
* stage: 2,
|
|
287
|
+
* features: {
|
|
288
|
+
* 'nesting-rules': true,
|
|
289
|
+
* 'custom-properties': true,
|
|
290
|
+
* 'color-functional-notation': true,
|
|
291
|
+
* },
|
|
292
|
+
* autoprefixer: {
|
|
293
|
+
* grid: true,
|
|
294
|
+
* },
|
|
295
|
+
* plugins: [],
|
|
296
|
+
* },
|
|
231
297
|
* useLog: {
|
|
232
298
|
* logLevel: 'warn',
|
|
233
299
|
* retentionDays: 7
|
|
234
300
|
* },
|
|
235
|
-
* useJsMap: true
|
|
236
|
-
* useCssMap: true
|
|
301
|
+
* useJsMap: true,
|
|
302
|
+
* useCssMap: true
|
|
237
303
|
* });
|
|
238
304
|
* ```
|
|
239
305
|
*/
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "uglify-js-minify-css-allfiles",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.8.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",
|
|
@@ -53,4 +53,4 @@
|
|
|
53
53
|
"uglify-js": "^3.19.2",
|
|
54
54
|
"uglify-js-es6": "^2.8.9"
|
|
55
55
|
}
|
|
56
|
-
}
|
|
56
|
+
}
|