@tailorkit/app 0.1.0-beta.12 → 0.1.0-beta.14
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/dist/builder.js +56 -25
- package/package.json +2 -2
package/dist/builder.js
CHANGED
|
@@ -126,6 +126,41 @@ var buildApp = async (options = {}) => {
|
|
|
126
126
|
const preactVersion = getInstalledPreactVersion(loaded.root);
|
|
127
127
|
assertSupportedPreactVersion(preactVersion);
|
|
128
128
|
const resolvedOutDir = path.resolve(loaded.root, outDir);
|
|
129
|
+
const writeBuildExtras = async () => {
|
|
130
|
+
const logoManifest = {};
|
|
131
|
+
for (const variant of ["light", "dark"]) {
|
|
132
|
+
const configuredPath = loaded.config.logos?.[variant];
|
|
133
|
+
if (!configuredPath) {
|
|
134
|
+
continue;
|
|
135
|
+
}
|
|
136
|
+
const extension = path.extname(configuredPath).toLowerCase().slice(1);
|
|
137
|
+
const contentType = { png: "image/png", svg: "image/svg+xml", webp: "image/webp" }[extension];
|
|
138
|
+
if (!contentType) {
|
|
139
|
+
throw new Error(`The ${variant} logo must be an SVG, PNG, or WebP file.`);
|
|
140
|
+
}
|
|
141
|
+
const content = await readFile(path.resolve(loaded.root, configuredPath));
|
|
142
|
+
validateLogoAsset(content, contentType);
|
|
143
|
+
const filename = `logo-${variant}.${extension}`;
|
|
144
|
+
await writeFile(path.join(resolvedOutDir, filename), content);
|
|
145
|
+
logoManifest[variant] = filename;
|
|
146
|
+
}
|
|
147
|
+
await writeFile(
|
|
148
|
+
path.join(resolvedOutDir, "tailorkit-upload.json"),
|
|
149
|
+
`${JSON.stringify(createTailorKitUploadManifest(logoManifest), null, 2)}
|
|
150
|
+
`,
|
|
151
|
+
"utf-8"
|
|
152
|
+
);
|
|
153
|
+
};
|
|
154
|
+
let firstBuildDone;
|
|
155
|
+
let firstBuildFailed;
|
|
156
|
+
const firstBuild = new Promise((resolve, reject) => {
|
|
157
|
+
firstBuildDone = resolve;
|
|
158
|
+
firstBuildFailed = reject;
|
|
159
|
+
});
|
|
160
|
+
if (!options.watch) {
|
|
161
|
+
void firstBuild.catch(() => {
|
|
162
|
+
});
|
|
163
|
+
}
|
|
129
164
|
const result = await viteBuild({
|
|
130
165
|
build: {
|
|
131
166
|
emptyOutDir: true,
|
|
@@ -151,7 +186,20 @@ var buildApp = async (options = {}) => {
|
|
|
151
186
|
},
|
|
152
187
|
configFile: false,
|
|
153
188
|
mode: options.mode,
|
|
189
|
+
oxc: { jsx: { importSource: "preact" } },
|
|
154
190
|
plugins: [
|
|
191
|
+
{
|
|
192
|
+
name: "tailorkit-preview-build-ready",
|
|
193
|
+
async closeBundle() {
|
|
194
|
+
try {
|
|
195
|
+
await writeBuildExtras();
|
|
196
|
+
firstBuildDone?.();
|
|
197
|
+
} catch (error) {
|
|
198
|
+
firstBuildFailed?.(error instanceof Error ? error : new Error(String(error)));
|
|
199
|
+
throw error;
|
|
200
|
+
}
|
|
201
|
+
}
|
|
202
|
+
},
|
|
155
203
|
{
|
|
156
204
|
name: "tailorkit-preact-package-json",
|
|
157
205
|
enforce: "pre",
|
|
@@ -172,33 +220,16 @@ var buildApp = async (options = {}) => {
|
|
|
172
220
|
],
|
|
173
221
|
root: loaded.root
|
|
174
222
|
});
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
const contentType = {
|
|
183
|
-
png: "image/png",
|
|
184
|
-
svg: "image/svg+xml",
|
|
185
|
-
webp: "image/webp"
|
|
186
|
-
}[extension];
|
|
187
|
-
if (!contentType) {
|
|
188
|
-
throw new Error(`The ${variant} logo must be an SVG, PNG, or WebP file.`);
|
|
223
|
+
if (options.watch) {
|
|
224
|
+
if (result && typeof result === "object" && "on" in result) {
|
|
225
|
+
result.on("event", (event) => {
|
|
226
|
+
if (event.code === "ERROR") {
|
|
227
|
+
firstBuildFailed?.(event.error ?? new Error("Initial app build failed."));
|
|
228
|
+
}
|
|
229
|
+
});
|
|
189
230
|
}
|
|
190
|
-
|
|
191
|
-
validateLogoAsset(content, contentType);
|
|
192
|
-
const filename = `logo-${variant}.${extension}`;
|
|
193
|
-
await writeFile(path.join(resolvedOutDir, filename), content);
|
|
194
|
-
logoManifest[variant] = filename;
|
|
231
|
+
await firstBuild;
|
|
195
232
|
}
|
|
196
|
-
await writeFile(
|
|
197
|
-
path.join(resolvedOutDir, "tailorkit-upload.json"),
|
|
198
|
-
`${JSON.stringify(createTailorKitUploadManifest(logoManifest), null, 2)}
|
|
199
|
-
`,
|
|
200
|
-
"utf-8"
|
|
201
|
-
);
|
|
202
233
|
return result;
|
|
203
234
|
};
|
|
204
235
|
function getInstalledPreactVersion(root) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tailorkit/app",
|
|
3
|
-
"version": "0.1.0-beta.
|
|
3
|
+
"version": "0.1.0-beta.14",
|
|
4
4
|
"license": "Apache-2.0",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -33,7 +33,7 @@
|
|
|
33
33
|
"access": "public"
|
|
34
34
|
},
|
|
35
35
|
"dependencies": {
|
|
36
|
-
"@tailorkit/core": "0.1.0-beta.
|
|
36
|
+
"@tailorkit/core": "0.1.0-beta.14",
|
|
37
37
|
"cosmiconfig": "^10.0.1",
|
|
38
38
|
"vite": "^8.3.0",
|
|
39
39
|
"zod": "^4.6.2"
|