ultimate-jekyll-manager 0.0.283 → 0.0.284
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.
|
@@ -19,10 +19,16 @@ const CACHE_BRANCH = 'cache-uj-imagemin';
|
|
|
19
19
|
// Variables
|
|
20
20
|
let githubCache;
|
|
21
21
|
|
|
22
|
+
// Supported image extensions
|
|
23
|
+
const ALL_IMAGE_EXTENSIONS = ['jpg', 'jpeg', 'png', 'gif', 'svg', 'webp'];
|
|
24
|
+
const RESPONSIVE_EXTENSIONS = new Set(['jpg', 'jpeg', 'png']);
|
|
25
|
+
const ALL_IMAGE_GLOB = `*.{${ALL_IMAGE_EXTENSIONS.join(',')}}`;
|
|
26
|
+
const RESPONSIVE_GLOB = `*.{${[...RESPONSIVE_EXTENSIONS].join(',')}}`;
|
|
27
|
+
|
|
22
28
|
// Glob
|
|
23
29
|
const input = [
|
|
24
30
|
// Files to include
|
|
25
|
-
|
|
31
|
+
`src/assets/images/**/${ALL_IMAGE_GLOB}`,
|
|
26
32
|
|
|
27
33
|
// Files to exclude
|
|
28
34
|
// '!dist/**',
|
|
@@ -132,7 +138,13 @@ async function imagemin(complete) {
|
|
|
132
138
|
return complete();
|
|
133
139
|
}
|
|
134
140
|
|
|
135
|
-
|
|
141
|
+
// Calculate expected output count for progress tracking
|
|
142
|
+
const expectedOutputs = filesToProcess.reduce((count, file) => {
|
|
143
|
+
const ext = path.extname(file).slice(1).toLowerCase();
|
|
144
|
+
return count + (RESPONSIVE_EXTENSIONS.has(ext) ? responsiveConfigs.length : 1);
|
|
145
|
+
}, 0);
|
|
146
|
+
|
|
147
|
+
logger.log(`🔄 Processing ${filesToProcess.length} images (${expectedOutputs} output files)`);
|
|
136
148
|
stats.optimized = filesToProcess.length;
|
|
137
149
|
|
|
138
150
|
// Track sizes for optimization
|
|
@@ -144,10 +156,13 @@ async function imagemin(complete) {
|
|
|
144
156
|
stats.optimizedFiles.push(path.relative(rootPathProject, file));
|
|
145
157
|
}
|
|
146
158
|
|
|
159
|
+
// Progress counter
|
|
160
|
+
let processedOutputs = 0;
|
|
161
|
+
|
|
147
162
|
// Process images
|
|
148
163
|
return src(filesToProcess, { base: 'src/assets/images' })
|
|
149
164
|
.pipe(responsive({
|
|
150
|
-
|
|
165
|
+
[`**/${RESPONSIVE_GLOB}`]: responsiveConfigs
|
|
151
166
|
}, {
|
|
152
167
|
quality: 80,
|
|
153
168
|
progressive: true,
|
|
@@ -159,8 +174,12 @@ async function imagemin(complete) {
|
|
|
159
174
|
}))
|
|
160
175
|
.pipe(dest(output))
|
|
161
176
|
.on('data', (file) => {
|
|
162
|
-
//
|
|
177
|
+
// Progress tracking
|
|
178
|
+
processedOutputs++;
|
|
163
179
|
const relativePath = path.relative(path.join(rootPathProject, output), file.path);
|
|
180
|
+
logger.log(`🖼️ ${processedOutputs}/${expectedOutputs}: ${relativePath}`);
|
|
181
|
+
|
|
182
|
+
// Save to cache
|
|
164
183
|
const cachePath = path.join(CACHE_DIR, 'images', relativePath);
|
|
165
184
|
jetpack.copy(file.path, cachePath, { overwrite: true });
|
|
166
185
|
|
|
@@ -308,9 +327,6 @@ async function determineFilesToProcess(files, meta, githubCache, stats) {
|
|
|
308
327
|
const filesToProcess = [];
|
|
309
328
|
const validCachePaths = new Set();
|
|
310
329
|
|
|
311
|
-
// File extensions that get responsive processing (multiple sizes + webp)
|
|
312
|
-
const RESPONSIVE_EXTENSIONS = new Set(['jpg', 'jpeg', 'png']);
|
|
313
|
-
|
|
314
330
|
for (const file of files) {
|
|
315
331
|
const relativePath = path.relative(rootPathProject, file);
|
|
316
332
|
const hash = githubCache ? githubCache.calculateHash(file) : null;
|
|
@@ -354,7 +370,7 @@ async function determineFilesToProcess(files, meta, githubCache, stats) {
|
|
|
354
370
|
const dst = path.join(output, dirName, name);
|
|
355
371
|
jetpack.copy(src, dst, { overwrite: true });
|
|
356
372
|
});
|
|
357
|
-
logger.log(`📦
|
|
373
|
+
logger.log(`📦 ${stats.fromCache + 1}/${files.length} from cache: ${relativePath}`);
|
|
358
374
|
stats.fromCache++;
|
|
359
375
|
stats.cachedFiles.push(relativePath);
|
|
360
376
|
|
|
@@ -94,6 +94,12 @@ function shouldHaveStableName(name) {
|
|
|
94
94
|
return bundleNaming.stable.some(pattern => pattern.test(name));
|
|
95
95
|
}
|
|
96
96
|
|
|
97
|
+
// Sanitize chunk/bundle names: strip leading underscores
|
|
98
|
+
// Jekyll ignores files starting with "_" so these won't be copied to _site
|
|
99
|
+
function sanitizeChunkName(name) {
|
|
100
|
+
return name.replace(/^_+/, '');
|
|
101
|
+
}
|
|
102
|
+
|
|
97
103
|
// Helper function to get webpack settings (called at runtime)
|
|
98
104
|
function getSettings() {
|
|
99
105
|
// Load UJM config
|
|
@@ -184,18 +190,18 @@ function getSettings() {
|
|
|
184
190
|
|
|
185
191
|
// https://github.com/webpack/webpack/issues/959
|
|
186
192
|
chunkFilename: (data) => {
|
|
187
|
-
const name = data.chunk.name;
|
|
193
|
+
const name = sanitizeChunkName(data.chunk.name);
|
|
188
194
|
|
|
189
195
|
// Check if this chunk should have a stable name
|
|
190
196
|
if (shouldHaveStableName(name)) {
|
|
191
|
-
return
|
|
197
|
+
return `${name}.chunk.js`;
|
|
192
198
|
}
|
|
193
199
|
|
|
194
200
|
// Otherwise, use hashed filename
|
|
195
|
-
return
|
|
201
|
+
return `${name}.chunk.[chunkhash].js`;
|
|
196
202
|
},
|
|
197
203
|
filename: (data) => {
|
|
198
|
-
const name = data.chunk.name;
|
|
204
|
+
const name = sanitizeChunkName(data.chunk.name);
|
|
199
205
|
|
|
200
206
|
// Check for special output paths
|
|
201
207
|
if (bundleNaming.specialPaths[name]) {
|
|
@@ -204,11 +210,11 @@ function getSettings() {
|
|
|
204
210
|
|
|
205
211
|
// Check if this bundle should have a stable name
|
|
206
212
|
if (shouldHaveStableName(name)) {
|
|
207
|
-
return
|
|
213
|
+
return `${name}.bundle.js`;
|
|
208
214
|
}
|
|
209
215
|
|
|
210
216
|
// Everything else gets hashed
|
|
211
|
-
return
|
|
217
|
+
return `${name}.bundle.[contenthash].js`;
|
|
212
218
|
},
|
|
213
219
|
},
|
|
214
220
|
resolveLoader: {
|