Skip to content

Commit

Permalink
Merge pull request #3 from zhujianxintian/master
Browse files Browse the repository at this point in the history
docx: update README.md for get manifest
  • Loading branch information
hemengke1997 authored Jul 10, 2024
2 parents 487e48e + 3fec9ee commit d87951d
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 1 deletion.
10 changes: 10 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -101,12 +101,22 @@ export default defineConfig({

### get manifest in client

Note: The code here can only be used in the project code, not in 'vite.config.ts' and other build time code, because it is generated after the build

```ts
import { manifest } from 'vite-plugin-public-typescript/client'

console.log(manifest)
```

If you need to get the 'manifest' at build time, such as custom implementation of your own vite plugin 'injectScript', use the following code

```ts
import { getManifest } from 'vite-plugin-public-typescript';

console.log(getManifest())
```

### SPA

In `SPA` applications, we can inject scripts into `index.html` via the `injectScripts` plugin.
Expand Down
11 changes: 10 additions & 1 deletion README.zh.md
Original file line number Diff line number Diff line change
Expand Up @@ -102,14 +102,23 @@ export default defineConfig({
})
```

### 获取manifest
### 获取 manifest

注意:这里的代码只能是在项目代码中使用, 不能在 `vite.config.ts` 以及其他构建时代码中使用, 因为他是在构建之后生成的

```ts
import { manifest } from 'vite-plugin-public-typescript/client'

console.log(manifest)
```

如果需要在构建时获取到 `manifest`, 例如自定义实现自己的 vite 插件 `injectScript`, 请使用下面的代码

```ts
import { getManifest } from 'vite-plugin-public-typescript';

console.log(getManifest())
```

### SPA

Expand Down

0 comments on commit d87951d

Please sign in to comment.