Skip to content

Commit

Permalink
docs: 📝 add instructions to the README
Browse files Browse the repository at this point in the history
  • Loading branch information
TheDutchCoder committed May 7, 2021
1 parent 73373c3 commit 17c8033
Showing 1 changed file with 45 additions and 0 deletions.
45 changes: 45 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,47 @@
# vite-plugin-add-scripts
A Vite plugin to add custom scripts to the index.html file

## Installation
```
npm install vite-plugin-add-scripts
```

## Usage
Add your plugin to the `plugins` array. You can also specify when the plugin
should be used with the `apply` option.

```js
// vite.config.js
import ViteAddScripts from 'vite-plugin-add-scripts'

export default {
plugins: [
{
...ViteAddScripts([
{
position: 'head',
content: '<script>window.foo = {}</script>'
}
]),
apply: 'build',
}
]
}
```

## Options
You can use the `position` option to add the script to either the head or the
body section of the index.html file

The `content` option is the actual content that gets written to the file.
Normally it would be a stringified version of the script tags and their
contents.

```js
...ViteAddScripts([
{
position: 'body', // or 'head'
content: '<sciprt>window.foo = {}</script>'
}
]),
```

0 comments on commit 17c8033

Please sign in to comment.