-
Notifications
You must be signed in to change notification settings - Fork 56
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
better support vite.config.js by default
- Loading branch information
Showing
7 changed files
with
137 additions
and
46 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
import { defineConfig } from "vite"; | ||
import solid from "vite-plugin-solid"; | ||
|
||
export default defineConfig({ | ||
plugins: [solid()], | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
import { loadConfig } from "c12"; | ||
|
||
import { createApp } from "./app.js"; | ||
|
||
/** | ||
* | ||
* @param {string | undefined} configFile | ||
* @returns {Promise<import("./app.js").App>} | ||
*/ | ||
export async function loadApp(configFile = undefined) { | ||
/** @type {{ config: import("./app.js").App }}*/ | ||
let { config: app } = await loadConfig( | ||
configFile | ||
? { | ||
configFile, | ||
} | ||
: { | ||
name: "app", | ||
}, | ||
); | ||
|
||
if (!app.config) { | ||
const { config } = await loadConfig({ | ||
name: "vite", | ||
}); | ||
|
||
if (config.config) { | ||
console.warn("Found vite.config.js with app config"); | ||
// @ts-expect-error trying to send c12's config as app | ||
return config; | ||
} else { | ||
console.warn("No app config found. Assuming SPA app."); | ||
return createApp({ | ||
routers: [ | ||
{ | ||
name: "public", | ||
mode: "static", | ||
dir: "./public", | ||
}, | ||
{ | ||
name: "client", | ||
mode: "spa", | ||
handler: "./index.html", | ||
build: { | ||
target: "browser", | ||
plugins: () => config.plugins ?? [], | ||
}, | ||
}, | ||
], | ||
}); | ||
} | ||
} | ||
|
||
return app; | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.