uglify-js-minify-css-allfiles 2.7.1 → 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 +10 -0
- package/package.json +1 -1
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
|
@@ -236,6 +236,15 @@ declare module 'uglify-js-minify-css-allfiles' {
|
|
|
236
236
|
*/
|
|
237
237
|
cssMinifyOptions?: CSSMinifyOptions;
|
|
238
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
|
+
|
|
239
248
|
/**
|
|
240
249
|
* Enables source map generation for JavaScript files during minification.
|
|
241
250
|
* Source maps help with debugging by mapping minified code back to original source code.
|
|
@@ -283,6 +292,7 @@ declare module 'uglify-js-minify-css-allfiles' {
|
|
|
283
292
|
* autoprefixer: {
|
|
284
293
|
* grid: true,
|
|
285
294
|
* },
|
|
295
|
+
* plugins: [],
|
|
286
296
|
* },
|
|
287
297
|
* useLog: {
|
|
288
298
|
* logLevel: 'warn',
|