Skip to content

Commit fd5cffb

Browse files
committed
fix(image): change keyword to image
1 parent 7b73172 commit fd5cffb

1 file changed

Lines changed: 14 additions & 14 deletions

File tree

packages/start/src/image/plugin/index.ts

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ function getImageTransformer(imagePath: string, outputTypes: string[], sizes: nu
6666
for (const format of outputTypes) {
6767
for (const size of sizes) {
6868
const variantName = "variant_" + format + "_" + size;
69-
const importPath = JSON.stringify(imagePath + "?start-image-" + format + "-" + size);
69+
const importPath = JSON.stringify(imagePath + "?image-" + format + "-" + size);
7070
imported += "import " + variantName + " from " + importPath + ";\n";
7171
exported += variantName + ",";
7272
}
@@ -82,7 +82,7 @@ function getImageTransformer(imagePath: string, outputTypes: string[], sizes: nu
8282
}
8383

8484
function getImageVariant(imagePath: string, target: StartImageFormat, size: number): string {
85-
return `import source from ${JSON.stringify(imagePath + "?start-image-raw-" + target + "-" + size)};
85+
return `import source from ${JSON.stringify(imagePath + "?image-raw-" + target + "-" + size)};
8686
export default {
8787
width: ${size},
8888
type: '${getMIMEFromFormat(target)}',
@@ -91,22 +91,22 @@ export default {
9191
}
9292

9393
function getImageEntryPoint(imagePath: string): string {
94-
return `import src from ${JSON.stringify(imagePath + "?start-image-source")};
95-
import transformer from ${JSON.stringify(imagePath + "?start-image-transformer")};
94+
return `import src from ${JSON.stringify(imagePath + "?image-source")};
95+
import transformer from ${JSON.stringify(imagePath + "?image-transformer")};
9696
9797
export default { src, transformer };
9898
`;
9999
}
100100

101-
const LOCAL_PATH = /\?start-image(-[a-z]+(-[0-9]+)?)?/;
102-
const REMOTE_PATH = "start-image:";
101+
const LOCAL_PATH = /\?image(-[a-z]+(-[0-9]+)?)?/;
102+
const REMOTE_PATH = "image:";
103103

104104
export const imagePlugin = (options: StartImageOptions) => {
105105
const plugins: Plugin[] = [];
106106
if (options.remote) {
107107
const transformUrl = options.remote.transformURL;
108108
plugins.push({
109-
name: "start-image/remote",
109+
name: "solid-start:image/remote",
110110
enforce: "pre",
111111
resolveId(id) {
112112
if (id.startsWith(REMOTE_PATH)) {
@@ -144,7 +144,7 @@ export default {
144144
const validInputFileExtensions = getValidFileExtensions(inputFormat);
145145

146146
plugins.push({
147-
name: "start-image/local",
147+
name: "solid-start:image/local",
148148
enforce: "pre",
149149
resolveId(id, importer) {
150150
if (LOCAL_PATH.test(id) && importer) {
@@ -168,32 +168,32 @@ export default {
168168
const originalPath = `${dir}/${name}.${actualExtension}`;
169169
const relativePath = `./${name}.${actualExtension}`;
170170
// Get the true source
171-
if (condition.startsWith("start-image-source")) {
171+
if (condition.startsWith("image-source")) {
172172
return await getImageSource(originalPath, relativePath);
173173
}
174174
// Get the transformer file
175-
if (condition.startsWith("start-image-transformer")) {
175+
if (condition.startsWith("image-transformer")) {
176176
return getImageTransformer(relativePath, outputFormat, sizes);
177177
}
178178
// Image transformer variant
179-
if (condition.startsWith("start-image-raw")) {
179+
if (condition.startsWith("image-raw")) {
180180
const [, , format, size] = condition.split("-");
181181
const hash = xxHash32(originalPath).toString(16);
182182
const filename = `i-${hash}-${size}.${getOutputFileFromFormat(format as StartImageFormat)}`;
183183
const image = transformImage(originalPath, format as StartImageFormat, +size!, quality);
184184
const buffer = await image.toBuffer();
185-
const basePath = path.join(".start-image", filename);
185+
const basePath = path.join(".image", filename);
186186
const targetPath = path.join(publicPath, basePath);
187187
await outputFile(targetPath, buffer);
188188
return `export default "/${basePath}"`;
189189
}
190190
// Image transformer variant
191-
if (condition.startsWith("start-image-")) {
191+
if (condition.startsWith("image-")) {
192192
const [, format, size] = condition.split("-");
193193

194194
return getImageVariant(relativePath, format as StartImageFormat, +size!);
195195
}
196-
if (condition.startsWith("start-image")) {
196+
if (condition.startsWith("image")) {
197197
return getImageEntryPoint(relativePath);
198198
}
199199
return null;

0 commit comments

Comments
 (0)