@lovable.dev/vite-tanstack-config 1.0.0 → 1.2.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 +37 -6
- package/dist/index.d.cts +13 -5
- package/dist/index.d.ts +13 -5
- package/dist/index.js +38 -7
- package/package.json +6 -2
package/dist/index.cjs
CHANGED
|
@@ -247,17 +247,25 @@ function devServerFnErrorLogger() {
|
|
|
247
247
|
}
|
|
248
248
|
};
|
|
249
249
|
}
|
|
250
|
-
function defineConfig(
|
|
251
|
-
return async (
|
|
250
|
+
function defineConfig(configOrOptions = {}) {
|
|
251
|
+
return async (env) => {
|
|
252
|
+
const { command, mode } = env;
|
|
252
253
|
const isSandbox = isSandboxEnvironment();
|
|
254
|
+
let options;
|
|
255
|
+
if (typeof configOrOptions === "function") {
|
|
256
|
+
const userConfig = await Promise.resolve(configOrOptions(env));
|
|
257
|
+
options = { vite: userConfig };
|
|
258
|
+
} else if (configOrOptions instanceof Promise) {
|
|
259
|
+
options = { vite: await configOrOptions };
|
|
260
|
+
} else {
|
|
261
|
+
const hasLovableKey = "vite" in configOrOptions || "clientErrorLogger" in configOrOptions || "serverFnErrorLogger" in configOrOptions || "cloudflare" in configOrOptions || "tanstackStart" in configOrOptions || "react" in configOrOptions || "envDefine" in configOrOptions;
|
|
262
|
+
options = hasLovableKey ? configOrOptions : { vite: configOrOptions };
|
|
263
|
+
}
|
|
253
264
|
const internalPlugins = [];
|
|
254
265
|
const tailwindcss = (await import("@tailwindcss/vite")).default;
|
|
255
266
|
internalPlugins.push(tailwindcss());
|
|
256
267
|
const tsConfigPaths = (await import("vite-tsconfig-paths")).default;
|
|
257
268
|
internalPlugins.push(tsConfigPaths({ projects: ["./tsconfig.json"] }));
|
|
258
|
-
if (command === "serve" && mode === "development") {
|
|
259
|
-
internalPlugins.push((0, import_lovable_tagger.componentTagger)());
|
|
260
|
-
}
|
|
261
269
|
if (options.clientErrorLogger !== false) {
|
|
262
270
|
internalPlugins.push(devClientErrorLogger());
|
|
263
271
|
}
|
|
@@ -274,11 +282,34 @@ function defineConfig(options = {}) {
|
|
|
274
282
|
} catch {
|
|
275
283
|
}
|
|
276
284
|
}
|
|
285
|
+
const { tanstackStart } = await import("@tanstack/react-start/plugin/vite");
|
|
286
|
+
internalPlugins.push(tanstackStart(options.tanstackStart));
|
|
287
|
+
const viteReact = (await import("@vitejs/plugin-react")).default;
|
|
288
|
+
internalPlugins.push(viteReact(options.react));
|
|
289
|
+
if (command === "serve" && mode === "development") {
|
|
290
|
+
internalPlugins.push((0, import_lovable_tagger.componentTagger)());
|
|
291
|
+
}
|
|
292
|
+
let envDefine = {};
|
|
293
|
+
if (options.envDefine !== false) {
|
|
294
|
+
const loadedEnv = (0, import_vite.loadEnv)(mode, process.cwd(), "VITE_");
|
|
295
|
+
for (const [key, value] of Object.entries(loadedEnv)) {
|
|
296
|
+
envDefine[`import.meta.env.${key}`] = JSON.stringify(value);
|
|
297
|
+
}
|
|
298
|
+
}
|
|
277
299
|
let config = {
|
|
300
|
+
define: envDefine,
|
|
278
301
|
resolve: {
|
|
279
302
|
alias: {
|
|
280
303
|
"@": `${process.cwd()}/src`
|
|
281
|
-
}
|
|
304
|
+
},
|
|
305
|
+
dedupe: [
|
|
306
|
+
"react",
|
|
307
|
+
"react-dom",
|
|
308
|
+
"react/jsx-runtime",
|
|
309
|
+
"react/jsx-dev-runtime",
|
|
310
|
+
"@tanstack/react-query",
|
|
311
|
+
"@tanstack/query-core"
|
|
312
|
+
]
|
|
282
313
|
},
|
|
283
314
|
plugins: [...internalPlugins, ...options.plugins ?? []]
|
|
284
315
|
};
|
package/dist/index.d.cts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { PluginOption, UserConfig } from 'vite';
|
|
1
|
+
import { PluginOption, UserConfig, ConfigEnv, UserConfigFnObject, UserConfigFnPromise, UserConfigFn } from 'vite';
|
|
2
2
|
|
|
3
3
|
interface LovableViteTanstackOptions {
|
|
4
4
|
plugins?: PluginOption[];
|
|
@@ -6,10 +6,18 @@ 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
|
-
declare function defineConfig(
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
16
|
+
declare function defineConfig(config: UserConfig): (env: ConfigEnv) => Promise<UserConfig>;
|
|
17
|
+
declare function defineConfig(config: Promise<UserConfig>): (env: ConfigEnv) => Promise<UserConfig>;
|
|
18
|
+
declare function defineConfig(config: UserConfigFnObject): (env: ConfigEnv) => Promise<UserConfig>;
|
|
19
|
+
declare function defineConfig(config: UserConfigFnPromise): (env: ConfigEnv) => Promise<UserConfig>;
|
|
20
|
+
declare function defineConfig(config: UserConfigFn): (env: ConfigEnv) => Promise<UserConfig>;
|
|
21
|
+
declare function defineConfig(options?: LovableViteTanstackOptions): (env: ConfigEnv) => Promise<UserConfig>;
|
|
14
22
|
|
|
15
23
|
export { type LovableViteTanstackOptions, defineConfig };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { PluginOption, UserConfig } from 'vite';
|
|
1
|
+
import { PluginOption, UserConfig, ConfigEnv, UserConfigFnObject, UserConfigFnPromise, UserConfigFn } from 'vite';
|
|
2
2
|
|
|
3
3
|
interface LovableViteTanstackOptions {
|
|
4
4
|
plugins?: PluginOption[];
|
|
@@ -6,10 +6,18 @@ 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
|
-
declare function defineConfig(
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
16
|
+
declare function defineConfig(config: UserConfig): (env: ConfigEnv) => Promise<UserConfig>;
|
|
17
|
+
declare function defineConfig(config: Promise<UserConfig>): (env: ConfigEnv) => Promise<UserConfig>;
|
|
18
|
+
declare function defineConfig(config: UserConfigFnObject): (env: ConfigEnv) => Promise<UserConfig>;
|
|
19
|
+
declare function defineConfig(config: UserConfigFnPromise): (env: ConfigEnv) => Promise<UserConfig>;
|
|
20
|
+
declare function defineConfig(config: UserConfigFn): (env: ConfigEnv) => Promise<UserConfig>;
|
|
21
|
+
declare function defineConfig(options?: LovableViteTanstackOptions): (env: ConfigEnv) => Promise<UserConfig>;
|
|
14
22
|
|
|
15
23
|
export { type LovableViteTanstackOptions, defineConfig };
|
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() {
|
|
@@ -213,17 +213,25 @@ function devServerFnErrorLogger() {
|
|
|
213
213
|
}
|
|
214
214
|
};
|
|
215
215
|
}
|
|
216
|
-
function defineConfig(
|
|
217
|
-
return async (
|
|
216
|
+
function defineConfig(configOrOptions = {}) {
|
|
217
|
+
return async (env) => {
|
|
218
|
+
const { command, mode } = env;
|
|
218
219
|
const isSandbox = isSandboxEnvironment();
|
|
220
|
+
let options;
|
|
221
|
+
if (typeof configOrOptions === "function") {
|
|
222
|
+
const userConfig = await Promise.resolve(configOrOptions(env));
|
|
223
|
+
options = { vite: userConfig };
|
|
224
|
+
} else if (configOrOptions instanceof Promise) {
|
|
225
|
+
options = { vite: await configOrOptions };
|
|
226
|
+
} else {
|
|
227
|
+
const hasLovableKey = "vite" in configOrOptions || "clientErrorLogger" in configOrOptions || "serverFnErrorLogger" in configOrOptions || "cloudflare" in configOrOptions || "tanstackStart" in configOrOptions || "react" in configOrOptions || "envDefine" in configOrOptions;
|
|
228
|
+
options = hasLovableKey ? configOrOptions : { vite: configOrOptions };
|
|
229
|
+
}
|
|
219
230
|
const internalPlugins = [];
|
|
220
231
|
const tailwindcss = (await import("@tailwindcss/vite")).default;
|
|
221
232
|
internalPlugins.push(tailwindcss());
|
|
222
233
|
const tsConfigPaths = (await import("vite-tsconfig-paths")).default;
|
|
223
234
|
internalPlugins.push(tsConfigPaths({ projects: ["./tsconfig.json"] }));
|
|
224
|
-
if (command === "serve" && mode === "development") {
|
|
225
|
-
internalPlugins.push(componentTagger());
|
|
226
|
-
}
|
|
227
235
|
if (options.clientErrorLogger !== false) {
|
|
228
236
|
internalPlugins.push(devClientErrorLogger());
|
|
229
237
|
}
|
|
@@ -240,11 +248,34 @@ function defineConfig(options = {}) {
|
|
|
240
248
|
} catch {
|
|
241
249
|
}
|
|
242
250
|
}
|
|
251
|
+
const { tanstackStart } = await import("@tanstack/react-start/plugin/vite");
|
|
252
|
+
internalPlugins.push(tanstackStart(options.tanstackStart));
|
|
253
|
+
const viteReact = (await import("@vitejs/plugin-react")).default;
|
|
254
|
+
internalPlugins.push(viteReact(options.react));
|
|
255
|
+
if (command === "serve" && mode === "development") {
|
|
256
|
+
internalPlugins.push(componentTagger());
|
|
257
|
+
}
|
|
258
|
+
let envDefine = {};
|
|
259
|
+
if (options.envDefine !== false) {
|
|
260
|
+
const loadedEnv = loadEnv(mode, process.cwd(), "VITE_");
|
|
261
|
+
for (const [key, value] of Object.entries(loadedEnv)) {
|
|
262
|
+
envDefine[`import.meta.env.${key}`] = JSON.stringify(value);
|
|
263
|
+
}
|
|
264
|
+
}
|
|
243
265
|
let config = {
|
|
266
|
+
define: envDefine,
|
|
244
267
|
resolve: {
|
|
245
268
|
alias: {
|
|
246
269
|
"@": `${process.cwd()}/src`
|
|
247
|
-
}
|
|
270
|
+
},
|
|
271
|
+
dedupe: [
|
|
272
|
+
"react",
|
|
273
|
+
"react-dom",
|
|
274
|
+
"react/jsx-runtime",
|
|
275
|
+
"react/jsx-dev-runtime",
|
|
276
|
+
"@tanstack/react-query",
|
|
277
|
+
"@tanstack/query-core"
|
|
278
|
+
]
|
|
248
279
|
},
|
|
249
280
|
plugins: [...internalPlugins, ...options.plugins ?? []]
|
|
250
281
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lovable.dev/vite-tanstack-config",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.2.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",
|