Skip to content

Commit

Permalink
Merge pull request #1 from zhujianxintian/master
Browse files Browse the repository at this point in the history
docs: update readme.md default config and details
  • Loading branch information
hemengke1997 authored Jul 8, 2024
2 parents 9826a7a + 9bfd2f0 commit ad81a4e
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
5 changes: 5 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -74,17 +74,22 @@ pnpm add vite-plugin-public-typescript -D

## Usage

Note: The default value of 'inputDir' in 'publicTypescript' is' public-typescript ', you can also reconfigure this property.
Then you need to create a folder with the same name in the same directory as' vite.config.ts' and create a '.ts' file inside it

```ts
// vite.config.ts
import { defineConfig } from 'vite'
import { publicTypescript } from 'vite-plugin-public-typescript'

export default defineConfig({
plugins: [
// If you use the default configuration, the source code location 'inputDir' defaults to 'public-typescript'
publicTypescript(),
injectScripts((manifest) => [
{
attrs: {
// The file name in the directory, for example, test.ts --> manifest.test
src: manifest.someScript,
},
injectTo: 'head',
Expand Down
5 changes: 5 additions & 0 deletions README.zh.md
Original file line number Diff line number Diff line change
Expand Up @@ -77,17 +77,22 @@ pnpm add vite-plugin-public-typescript -D

## 用法

注意: `publicTypescript``inputDir` 默认值为 `public-typescript`,你也可以重新配置该属性。
之后你需要在与 `vite.config.ts` 同级目录下中创建同名文件夹, 在里面创建 `.ts` 文件

```ts
// vite.config.ts
import { defineConfig } from 'vite'
import { injectScripts, publicTypescript } from 'vite-plugin-public-typescript'

export default defineConfig({
plugins: [
// 如果使用默认配置, 则存放源代码的位置 `inputDir` 默认为 `public-typescript`
publicTypescript(),
injectScripts((manifest) => [
{
attrs: {
// 目录下的文件名, 例如: test.ts --> manifest.test
src: manifest.someScript,
},
injectTo: 'head',
Expand Down

0 comments on commit ad81a4e

Please sign in to comment.