-
-
Notifications
You must be signed in to change notification settings - Fork 359
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
10 changed files
with
103 additions
and
23 deletions.
There are no files selected for viewing
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,47 @@ | ||
import { Warning, Link } from '@brillout/docpress' | ||
|
||
Environment: Vite. | ||
|
||
Get all the information Vike knows about the app in your Vite plugin. | ||
|
||
<Warning>It's a beta feature: expect breaking changes in any minor version update.</Warning> | ||
|
||
> It provides all configurations loaded at build-time set by <Link href="/config#files">`+` files</Link> and <Link href="/extensions">Vike extensions</Link>. | ||
> | ||
> You can also use `globalContext.config` and `globalContext.pages` to get all configurations loaded at runtime, see <Link href="/getGlobalContext" />. | ||
```js | ||
// vite.config.js | ||
|
||
import { getVikeConfig } from 'vike/plugin' | ||
|
||
export default { | ||
plugins: [myVitePlugin()] | ||
} | ||
|
||
function myVitePlugin() { | ||
return { | ||
name: 'myVitePlugin', | ||
configResolved(config) { | ||
const vike = getVikeConfig(config) | ||
console.log(vike.config.prerender) | ||
console.log(vike.config.baseAssets) | ||
console.log(vike.config.baseServer) | ||
console.log(vike.pages['/pages/index'].config) | ||
console.log(vike.pages['/pages/product'].route) | ||
// ... | ||
}, | ||
config(config) { | ||
// Also available here | ||
const vike = getVikeConfig(config) | ||
} | ||
} | ||
} | ||
``` | ||
|
||
## See also | ||
|
||
- <Link href="/config#files" /> | ||
- <Link href="/getGlobalContext" /> | ||
- [Vite > Plugin API > `configResolved`](https://vite.dev/guide/api-plugin.html#configresolved) | ||
- [Vite > Plugin API > `config`](https://vite.dev/guide/api-plugin.html#config) |
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
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
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