Skip to content

Commit

Permalink
Merge pull request #3 from TheDutchCoder/update-readme
Browse files Browse the repository at this point in the history
docs: 📝 add instructions to the README
  • Loading branch information
TheDutchCoder authored May 7, 2021
2 parents 73373c3 + 5c189b7 commit adf7e78
Show file tree
Hide file tree
Showing 5 changed files with 2,253 additions and 99 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 --save-dev
```

## 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>'
}
]),
```
Loading

0 comments on commit adf7e78

Please sign in to comment.