@lovable.dev/vite-tanstack-config 1.1.0 → 1.3.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/dist/index.cjs +43 -6
- package/dist/index.d.cts +6 -0
- package/dist/index.d.ts +6 -0
- package/dist/index.js +44 -7
- package/package.json +6 -2
package/dist/index.cjs
CHANGED
|
@@ -113,6 +113,23 @@ function cleanServerConfig(config) {
|
|
|
113
113
|
}
|
|
114
114
|
return config;
|
|
115
115
|
}
|
|
116
|
+
function applyWatchDebounceDefaults(config) {
|
|
117
|
+
const existingWatch = config.server?.watch ?? {};
|
|
118
|
+
const existingAwaitWriteFinish = existingWatch.awaitWriteFinish;
|
|
119
|
+
const hasAwaitWriteFinishObject = !!existingAwaitWriteFinish && typeof existingAwaitWriteFinish === "object" && !Array.isArray(existingAwaitWriteFinish);
|
|
120
|
+
return (0, import_vite.mergeConfig)(config, {
|
|
121
|
+
server: {
|
|
122
|
+
watch: {
|
|
123
|
+
...existingWatch,
|
|
124
|
+
awaitWriteFinish: {
|
|
125
|
+
...hasAwaitWriteFinishObject ? existingAwaitWriteFinish : {},
|
|
126
|
+
stabilityThreshold: 1e3,
|
|
127
|
+
pollInterval: 100
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
});
|
|
132
|
+
}
|
|
116
133
|
function devClientErrorLogger() {
|
|
117
134
|
const VIRTUAL_ID = "virtual:dev-client-error-handler";
|
|
118
135
|
const RESOLVED_ID = "\0" + VIRTUAL_ID;
|
|
@@ -258,7 +275,7 @@ function defineConfig(configOrOptions = {}) {
|
|
|
258
275
|
} else if (configOrOptions instanceof Promise) {
|
|
259
276
|
options = { vite: await configOrOptions };
|
|
260
277
|
} else {
|
|
261
|
-
const hasLovableKey = "vite" in configOrOptions || "clientErrorLogger" in configOrOptions || "serverFnErrorLogger" in configOrOptions || "cloudflare" in configOrOptions;
|
|
278
|
+
const hasLovableKey = "vite" in configOrOptions || "clientErrorLogger" in configOrOptions || "serverFnErrorLogger" in configOrOptions || "cloudflare" in configOrOptions || "tanstackStart" in configOrOptions || "react" in configOrOptions || "envDefine" in configOrOptions;
|
|
262
279
|
options = hasLovableKey ? configOrOptions : { vite: configOrOptions };
|
|
263
280
|
}
|
|
264
281
|
const internalPlugins = [];
|
|
@@ -266,9 +283,6 @@ function defineConfig(configOrOptions = {}) {
|
|
|
266
283
|
internalPlugins.push(tailwindcss());
|
|
267
284
|
const tsConfigPaths = (await import("vite-tsconfig-paths")).default;
|
|
268
285
|
internalPlugins.push(tsConfigPaths({ projects: ["./tsconfig.json"] }));
|
|
269
|
-
if (command === "serve" && mode === "development") {
|
|
270
|
-
internalPlugins.push((0, import_lovable_tagger.componentTagger)());
|
|
271
|
-
}
|
|
272
286
|
if (options.clientErrorLogger !== false) {
|
|
273
287
|
internalPlugins.push(devClientErrorLogger());
|
|
274
288
|
}
|
|
@@ -285,11 +299,34 @@ function defineConfig(configOrOptions = {}) {
|
|
|
285
299
|
} catch {
|
|
286
300
|
}
|
|
287
301
|
}
|
|
302
|
+
const { tanstackStart } = await import("@tanstack/react-start/plugin/vite");
|
|
303
|
+
internalPlugins.push(tanstackStart(options.tanstackStart));
|
|
304
|
+
const viteReact = (await import("@vitejs/plugin-react")).default;
|
|
305
|
+
internalPlugins.push(viteReact(options.react));
|
|
306
|
+
if (command === "serve" && mode === "development") {
|
|
307
|
+
internalPlugins.push((0, import_lovable_tagger.componentTagger)());
|
|
308
|
+
}
|
|
309
|
+
let envDefine = {};
|
|
310
|
+
if (options.envDefine !== false) {
|
|
311
|
+
const loadedEnv = (0, import_vite.loadEnv)(mode, process.cwd(), "VITE_");
|
|
312
|
+
for (const [key, value] of Object.entries(loadedEnv)) {
|
|
313
|
+
envDefine[`import.meta.env.${key}`] = JSON.stringify(value);
|
|
314
|
+
}
|
|
315
|
+
}
|
|
288
316
|
let config = {
|
|
317
|
+
define: envDefine,
|
|
289
318
|
resolve: {
|
|
290
319
|
alias: {
|
|
291
320
|
"@": `${process.cwd()}/src`
|
|
292
|
-
}
|
|
321
|
+
},
|
|
322
|
+
dedupe: [
|
|
323
|
+
"react",
|
|
324
|
+
"react-dom",
|
|
325
|
+
"react/jsx-runtime",
|
|
326
|
+
"react/jsx-dev-runtime",
|
|
327
|
+
"@tanstack/react-query",
|
|
328
|
+
"@tanstack/query-core"
|
|
329
|
+
]
|
|
293
330
|
},
|
|
294
331
|
plugins: [...internalPlugins, ...options.plugins ?? []]
|
|
295
332
|
};
|
|
@@ -306,7 +343,7 @@ function defineConfig(configOrOptions = {}) {
|
|
|
306
343
|
} else {
|
|
307
344
|
config = (0, import_vite.mergeConfig)({ server: { host: "::", port: 8080 } }, config);
|
|
308
345
|
}
|
|
309
|
-
return config;
|
|
346
|
+
return applyWatchDebounceDefaults(config);
|
|
310
347
|
};
|
|
311
348
|
}
|
|
312
349
|
// Annotate the CommonJS export names for ESM import in node:
|
package/dist/index.d.cts
CHANGED
|
@@ -6,6 +6,12 @@ interface LovableViteTanstackOptions {
|
|
|
6
6
|
clientErrorLogger?: boolean;
|
|
7
7
|
serverFnErrorLogger?: boolean;
|
|
8
8
|
cloudflare?: Record<string, unknown> | false;
|
|
9
|
+
/** Options forwarded to tanstackStart(). */
|
|
10
|
+
tanstackStart?: Record<string, unknown>;
|
|
11
|
+
/** Options forwarded to viteReact(). */
|
|
12
|
+
react?: Record<string, unknown>;
|
|
13
|
+
/** Set to false to disable automatic VITE_* env define injection. Default: true. */
|
|
14
|
+
envDefine?: boolean;
|
|
9
15
|
}
|
|
10
16
|
declare function defineConfig(config: UserConfig): (env: ConfigEnv) => Promise<UserConfig>;
|
|
11
17
|
declare function defineConfig(config: Promise<UserConfig>): (env: ConfigEnv) => Promise<UserConfig>;
|
package/dist/index.d.ts
CHANGED
|
@@ -6,6 +6,12 @@ interface LovableViteTanstackOptions {
|
|
|
6
6
|
clientErrorLogger?: boolean;
|
|
7
7
|
serverFnErrorLogger?: boolean;
|
|
8
8
|
cloudflare?: Record<string, unknown> | false;
|
|
9
|
+
/** Options forwarded to tanstackStart(). */
|
|
10
|
+
tanstackStart?: Record<string, unknown>;
|
|
11
|
+
/** Options forwarded to viteReact(). */
|
|
12
|
+
react?: Record<string, unknown>;
|
|
13
|
+
/** Set to false to disable automatic VITE_* env define injection. Default: true. */
|
|
14
|
+
envDefine?: boolean;
|
|
9
15
|
}
|
|
10
16
|
declare function defineConfig(config: UserConfig): (env: ConfigEnv) => Promise<UserConfig>;
|
|
11
17
|
declare function defineConfig(config: Promise<UserConfig>): (env: ConfigEnv) => Promise<UserConfig>;
|
package/dist/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
// src/index.ts
|
|
2
2
|
import { componentTagger } from "lovable-tagger";
|
|
3
|
-
import { mergeConfig } from "vite";
|
|
3
|
+
import { mergeConfig, loadEnv } from "vite";
|
|
4
4
|
var SANDBOX_ENV_VAR = "DEV_SERVER__PROJECT_PATH";
|
|
5
5
|
var LOVABLE_SANDBOX_ENV_VAR = "LOVABLE_SANDBOX";
|
|
6
6
|
function isSandboxEnvironment() {
|
|
@@ -79,6 +79,23 @@ function cleanServerConfig(config) {
|
|
|
79
79
|
}
|
|
80
80
|
return config;
|
|
81
81
|
}
|
|
82
|
+
function applyWatchDebounceDefaults(config) {
|
|
83
|
+
const existingWatch = config.server?.watch ?? {};
|
|
84
|
+
const existingAwaitWriteFinish = existingWatch.awaitWriteFinish;
|
|
85
|
+
const hasAwaitWriteFinishObject = !!existingAwaitWriteFinish && typeof existingAwaitWriteFinish === "object" && !Array.isArray(existingAwaitWriteFinish);
|
|
86
|
+
return mergeConfig(config, {
|
|
87
|
+
server: {
|
|
88
|
+
watch: {
|
|
89
|
+
...existingWatch,
|
|
90
|
+
awaitWriteFinish: {
|
|
91
|
+
...hasAwaitWriteFinishObject ? existingAwaitWriteFinish : {},
|
|
92
|
+
stabilityThreshold: 1e3,
|
|
93
|
+
pollInterval: 100
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
});
|
|
98
|
+
}
|
|
82
99
|
function devClientErrorLogger() {
|
|
83
100
|
const VIRTUAL_ID = "virtual:dev-client-error-handler";
|
|
84
101
|
const RESOLVED_ID = "\0" + VIRTUAL_ID;
|
|
@@ -224,7 +241,7 @@ function defineConfig(configOrOptions = {}) {
|
|
|
224
241
|
} else if (configOrOptions instanceof Promise) {
|
|
225
242
|
options = { vite: await configOrOptions };
|
|
226
243
|
} else {
|
|
227
|
-
const hasLovableKey = "vite" in configOrOptions || "clientErrorLogger" in configOrOptions || "serverFnErrorLogger" in configOrOptions || "cloudflare" in configOrOptions;
|
|
244
|
+
const hasLovableKey = "vite" in configOrOptions || "clientErrorLogger" in configOrOptions || "serverFnErrorLogger" in configOrOptions || "cloudflare" in configOrOptions || "tanstackStart" in configOrOptions || "react" in configOrOptions || "envDefine" in configOrOptions;
|
|
228
245
|
options = hasLovableKey ? configOrOptions : { vite: configOrOptions };
|
|
229
246
|
}
|
|
230
247
|
const internalPlugins = [];
|
|
@@ -232,9 +249,6 @@ function defineConfig(configOrOptions = {}) {
|
|
|
232
249
|
internalPlugins.push(tailwindcss());
|
|
233
250
|
const tsConfigPaths = (await import("vite-tsconfig-paths")).default;
|
|
234
251
|
internalPlugins.push(tsConfigPaths({ projects: ["./tsconfig.json"] }));
|
|
235
|
-
if (command === "serve" && mode === "development") {
|
|
236
|
-
internalPlugins.push(componentTagger());
|
|
237
|
-
}
|
|
238
252
|
if (options.clientErrorLogger !== false) {
|
|
239
253
|
internalPlugins.push(devClientErrorLogger());
|
|
240
254
|
}
|
|
@@ -251,11 +265,34 @@ function defineConfig(configOrOptions = {}) {
|
|
|
251
265
|
} catch {
|
|
252
266
|
}
|
|
253
267
|
}
|
|
268
|
+
const { tanstackStart } = await import("@tanstack/react-start/plugin/vite");
|
|
269
|
+
internalPlugins.push(tanstackStart(options.tanstackStart));
|
|
270
|
+
const viteReact = (await import("@vitejs/plugin-react")).default;
|
|
271
|
+
internalPlugins.push(viteReact(options.react));
|
|
272
|
+
if (command === "serve" && mode === "development") {
|
|
273
|
+
internalPlugins.push(componentTagger());
|
|
274
|
+
}
|
|
275
|
+
let envDefine = {};
|
|
276
|
+
if (options.envDefine !== false) {
|
|
277
|
+
const loadedEnv = loadEnv(mode, process.cwd(), "VITE_");
|
|
278
|
+
for (const [key, value] of Object.entries(loadedEnv)) {
|
|
279
|
+
envDefine[`import.meta.env.${key}`] = JSON.stringify(value);
|
|
280
|
+
}
|
|
281
|
+
}
|
|
254
282
|
let config = {
|
|
283
|
+
define: envDefine,
|
|
255
284
|
resolve: {
|
|
256
285
|
alias: {
|
|
257
286
|
"@": `${process.cwd()}/src`
|
|
258
|
-
}
|
|
287
|
+
},
|
|
288
|
+
dedupe: [
|
|
289
|
+
"react",
|
|
290
|
+
"react-dom",
|
|
291
|
+
"react/jsx-runtime",
|
|
292
|
+
"react/jsx-dev-runtime",
|
|
293
|
+
"@tanstack/react-query",
|
|
294
|
+
"@tanstack/query-core"
|
|
295
|
+
]
|
|
259
296
|
},
|
|
260
297
|
plugins: [...internalPlugins, ...options.plugins ?? []]
|
|
261
298
|
};
|
|
@@ -272,7 +309,7 @@ function defineConfig(configOrOptions = {}) {
|
|
|
272
309
|
} else {
|
|
273
310
|
config = mergeConfig({ server: { host: "::", port: 8080 } }, config);
|
|
274
311
|
}
|
|
275
|
-
return config;
|
|
312
|
+
return applyWatchDebounceDefaults(config);
|
|
276
313
|
};
|
|
277
314
|
}
|
|
278
315
|
export {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lovable.dev/vite-tanstack-config",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.3.0",
|
|
4
4
|
"description": "Vite config wrapper for Lovable TanStack Start projects",
|
|
5
5
|
"main": "./dist/index.cjs",
|
|
6
6
|
"module": "./dist/index.js",
|
|
@@ -32,7 +32,9 @@
|
|
|
32
32
|
"vite": ">=5.0.0 <9.0.0",
|
|
33
33
|
"@tailwindcss/vite": ">=4.0.0",
|
|
34
34
|
"vite-tsconfig-paths": ">=6.0.0",
|
|
35
|
-
"@cloudflare/vite-plugin": ">=1.0.0"
|
|
35
|
+
"@cloudflare/vite-plugin": ">=1.0.0",
|
|
36
|
+
"@tanstack/react-start": ">=1.100.0",
|
|
37
|
+
"@vitejs/plugin-react": ">=4.0.0"
|
|
36
38
|
},
|
|
37
39
|
"peerDependenciesMeta": {
|
|
38
40
|
"@cloudflare/vite-plugin": {
|
|
@@ -41,6 +43,8 @@
|
|
|
41
43
|
},
|
|
42
44
|
"devDependencies": {
|
|
43
45
|
"@cloudflare/vite-plugin": "^1.25.5",
|
|
46
|
+
"@tanstack/react-start": "^1.162.9",
|
|
47
|
+
"@vitejs/plugin-react": "^4.5.2",
|
|
44
48
|
"@tailwindcss/vite": "^4.2.1",
|
|
45
49
|
"@types/node": "catalog:",
|
|
46
50
|
"rimraf": "^5.0.0",
|