@koehler8/cms 1.0.0-beta.25 → 1.0.0-beta.26
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/package.json
CHANGED
|
@@ -136,13 +136,25 @@ export function planVariantJobs({ siteDir, config }) {
|
|
|
136
136
|
const baseName = parsed.name;
|
|
137
137
|
|
|
138
138
|
const outputs = [];
|
|
139
|
+
|
|
140
|
+
// Copy the source to the flat dir under its bare name. Components that
|
|
141
|
+
// reference assets by their bare path (`resolveAsset('img/logo.png')`,
|
|
142
|
+
// useResponsiveImage's `${basePath}.${format}` fallback) need the
|
|
143
|
+
// original present at `site/assets/img/{name}.{ext}`; without this,
|
|
144
|
+
// sites that migrate originals into _source/ break every bare-path
|
|
145
|
+
// lookup.
|
|
146
|
+
outputs.push({
|
|
147
|
+
kind: 'copy',
|
|
148
|
+
outPath: path.join(imgDir, subdir, parsed.base),
|
|
149
|
+
});
|
|
150
|
+
|
|
139
151
|
for (const width of config.widths) {
|
|
140
152
|
for (const format of config.formats) {
|
|
141
153
|
const ext = FORMAT_OUTPUT_EXT[format];
|
|
142
154
|
if (!ext) continue;
|
|
143
155
|
const outName = `${baseName}-${width}.${ext}`;
|
|
144
156
|
const outPath = path.join(imgDir, subdir, outName);
|
|
145
|
-
outputs.push({ width, format, outPath });
|
|
157
|
+
outputs.push({ kind: 'variant', width, format, outPath });
|
|
146
158
|
}
|
|
147
159
|
}
|
|
148
160
|
jobs.push({ sourcePath, outputs });
|
|
@@ -155,6 +167,11 @@ async function renderOutput(sourcePath, output, config) {
|
|
|
155
167
|
const { width, format, outPath } = output;
|
|
156
168
|
await fs.promises.mkdir(path.dirname(outPath), { recursive: true });
|
|
157
169
|
|
|
170
|
+
if (output.kind === 'copy') {
|
|
171
|
+
await fs.promises.copyFile(sourcePath, outPath);
|
|
172
|
+
return;
|
|
173
|
+
}
|
|
174
|
+
|
|
158
175
|
let pipeline = sharp(sourcePath, { failOn: 'truncated' }).rotate();
|
|
159
176
|
pipeline = pipeline.resize({ width, withoutEnlargement: true });
|
|
160
177
|
switch (format) {
|