-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
8 changed files
with
107 additions
and
2 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
# Vite SSG/SSE | ||
|
||
If you are using `vite-sse` or `vite-ssg`. Follow the following steps to setup `naive-ui`. | ||
|
||
## 1. Install `naive-ui`, `@css-render/vue3-ssr` | ||
|
||
```bash | ||
# pnpm | ||
pnpm i naive-ui @css-render/vue3-ssr | ||
|
||
# npm | ||
npm i naive-ui @css-render/vue3-ssr | ||
``` | ||
|
||
## 2. Modify `vite.config.ts` | ||
|
||
Add following content. If there exists content already, merge them. | ||
|
||
```ts | ||
import { setup } from '@css-render/vue3-ssr' | ||
|
||
defineConfig({ | ||
ssr: { | ||
noExternal: ['naive-ui', 'vueuc', 'date-fns'] | ||
}, | ||
ssgOptions: { | ||
async onBeforePageRender(_, __, appCtx) { | ||
const { collect } = setup(appCtx.app) | ||
;(appCtx as any).__collectStyle = collect | ||
return undefined | ||
}, | ||
async onPageRendered(_, renderedHTML, appCtx) { | ||
return renderedHTML.replace( | ||
/<\/head>/, | ||
`${(appCtx as any).__collectStyle()}</head>` | ||
) | ||
} | ||
} | ||
}) | ||
``` | ||
|
||
Then you can using naive-ui in `vite-ssg` or `vite-sse` project. |
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,42 @@ | ||
# Vite SSG/SSE | ||
|
||
如果你正在使用 `vite-sse` 或者 `vite-ssg`,通过下面的步骤设定 `naive-ui`。 | ||
|
||
## 1. 安装 `naive-ui`、`@css-render/vue3-ssr` | ||
|
||
```bash | ||
# pnpm | ||
pnpm i naive-ui @css-render/vue3-ssr | ||
|
||
# npm | ||
npm i naive-ui @css-render/vue3-ssr | ||
``` | ||
|
||
## 2. 修改 `vite.config.ts` | ||
|
||
增加下列内容,如果已经存在一些内容,则合并他们。 | ||
|
||
```ts | ||
import { setup } from '@css-render/vue3-ssr' | ||
|
||
defineConfig({ | ||
ssr: { | ||
noExternal: ['naive-ui', 'vueuc', 'date-fns'] | ||
}, | ||
ssgOptions: { | ||
async onBeforePageRender(_, __, appCtx) { | ||
const { collect } = setup(appCtx.app) | ||
;(appCtx as any).__collectStyle = collect | ||
return undefined | ||
}, | ||
async onPageRendered(_, renderedHTML, appCtx) { | ||
return renderedHTML.replace( | ||
/<\/head>/, | ||
`${(appCtx as any).__collectStyle()}</head>` | ||
) | ||
} | ||
} | ||
}) | ||
``` | ||
|
||
现在你可以在 `vite-ssg` 或 `vite-sse` 项目中使用 `naive-ui` 了。 |
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