forked from vikejs/vike
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Co-authored-by: Romuald Brillout <[email protected]>
- Loading branch information
Showing
97 changed files
with
722 additions
and
311 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
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
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,70 @@ | ||
import { Link } from '@brillout/docpress' | ||
|
||
```js | ||
import { dev, build, preview, prerender } from 'vike/api' | ||
|
||
// Same as CLI `$ vike dev` | ||
await dev() | ||
console.log('Dev server is ready') | ||
|
||
// Same as CLI `$ vike build` | ||
await build() | ||
console.log('Build is done') | ||
|
||
// Same as CLI `$ vike preview` | ||
await preview() | ||
console.log('Preview server is ready') | ||
|
||
// Same as CLI `$ vike prerender` | ||
await prerender() | ||
console.log('Pre-rendering is done') | ||
``` | ||
|
||
## Options | ||
|
||
All API functions have the option `{ viteConfig: { /*...*/ }}`. (It's the only option.) | ||
|
||
> We generally recommend to define your Vite settings in your `vite.config.js` file instead of using the `viteConfig` option. The API automatically loads your `vite.config.js` file (just like the CLI). | ||
If you want to define Vite settings outside of your app (typically when <Link href="/build-your-own-framework">building your own framework</Link>) you can do this: | ||
|
||
```js | ||
import { dev } from 'vike/api' | ||
|
||
await dev({ | ||
viteConfig: { | ||
// vite.config.js can live in node_modules/my-framework/src/vite.config.ts | ||
configFile: './path/to/vite.config.js', | ||
// The app's root can be somewhere completely else than vite.config.js | ||
root: './path/to/app/' | ||
// Some Vite settings overriding vite.config.js | ||
/* ... */ | ||
} | ||
}) | ||
console.log('Dev server is ready') | ||
``` | ||
|
||
If you want to define your entire Vite config programmatically: | ||
|
||
```js | ||
import { build } from 'vike/api' | ||
|
||
await build({ | ||
viteConfig: { | ||
// Don't load any vite.config.js | ||
configFile: false, | ||
// All Vite settings | ||
/* ... */ | ||
} | ||
}) | ||
console.log('Build is done') | ||
``` | ||
|
||
See also: [Vite > JavaScript API > `InlineConfig`](https://vitejs.dev/guide/api-javascript.html#inlineconfig) | ||
|
||
|
||
## See also | ||
|
||
- [Vite > JavaScript API](https://vite.dev/guide/api-javascript) | ||
- <Link href="/cli" /> | ||
- <Link href="/build-your-own-framework" /> |
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,28 @@ | ||
import { Link } from '@brillout/docpress' | ||
|
||
Usage: | ||
- `$ vike dev` Start development server. | ||
- `$ vike build` Build for production. | ||
- `$ vike preview` Start preview server using production build. | ||
- `$ vike prerender` <Link href="/pre-rendering">Pre-render</Link> pages. | ||
- `$ vike -v` Print Vike's installed version. | ||
|
||
Vike's CLI doesn't have any options, instead: | ||
- change your `vite.config.js` file, or | ||
- use the `VITE_CONFIG` environment variable. | ||
|
||
For example: | ||
|
||
```bash | ||
# Set Vite's server.host setting to true | ||
$ VITE_CONFIG="{server:{host:true}}" vike dev | ||
|
||
# When running Vike's CLI over a package.json script | ||
$ VITE_CONFIG="{build:{outDir:'build'}}" npm run build | ||
``` | ||
|
||
> You can define `VITE_CONFIG` using JavaScript-like syntax, [JSON syntax](https://json.org/example.html), or [JSON5 syntax](https://json5.org/#example). (Vike uses [JSON5](https://json5.org) to parse `VITE_CONFIG`.) | ||
## See also | ||
|
||
- <Link href="/api" /> |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
import { Link } from '@brillout/docpress' | ||
|
||
Using the Vite CLI is deprecated starting from `[email protected]`. | ||
|
||
> You can still use it, but you'll see following warning and support for Vite's CLI will be completely removed in the next major release. | ||
> ``` | ||
> 1:18:05 PM [vike][Warning] The Vite CLI is deprecated | ||
> ``` | ||
Use the Vike CLI instead: | ||
```json5 | ||
// package.json | ||
{ | ||
"scripts": { | ||
"dev": "vite", // [!code --] | ||
"dev": "vike dev", // [!code ++] | ||
"build": "vite build", // [!code --] | ||
"build": "vike build", // [!code ++] | ||
"preview": "vite preview", // [!code --] | ||
"preview": "vike preview", // [!code ++] | ||
} | ||
} | ||
``` | ||
Vike's CLI doesn't have any option: use the `VITE_CONFIG` environment variable instead, see <Link href="/cli" />. | ||
|
||
We also recommend using <Link href="/api">Vike's JavaScript API</Link> instead of [Vite's JavaScript API](https://vite.dev/guide/api-javascript), as some features in the near future will only be available when using Vike's JavaScript API. | ||
|
||
## See also | ||
|
||
- <Link href="/cli" /> | ||
- <Link href="/api" /> |
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
Oops, something went wrong.