Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/aminnairi/rollup-plugin-create-html

Create HTML files when bundling your Rollup assets
https://github.com/aminnairi/rollup-plugin-create-html

create html plugin rollup

Last synced: about 5 hours ago
JSON representation

Create HTML files when bundling your Rollup assets

Awesome Lists containing this project

README

        

# @aminnairi/rollup-plugin-create-html

## Requirements

- Node
- NPM

## Installation

```bash
npm install @aminnairi/rollup-plugin-create-html
```

## Usage

```javascript
import { createHtml } from "./sources/rollup-plugin-create-html";

export default {
input: "sources/index.js",
plugins: [
createHtml({
name: "index.html",
path: ".",
doctype: "",
root: {
name: "html",
attributes: {
lang: "en-US"
},
children: [
{
name: "head",
children: [
{ name: "meta", attributes: { charset: "UTF-8" } },
{ name: "meta", attributes: { name: "description", content: "description" } },
{ name: "meta", attributes: { name: "viewport", content: "width=device-width, initial-scale=1.0" } },
{ name: "title", children: ["title"] }
]
},
{
name: "body",
children: [
{ name: "div", attributes: { id: "root" }, children: [] },
{ name: "script", attributes: { src: "index.js", async: true, defer: true }, children: [] }
]
}
]
}
})
],
output: {
file: "build/index.js",
format: "iife"
}
}
```

```html





title




```

## Options

### Name

The name of the file to generate. This should not include any folder.

```javascript
import { createHtml } from "@aminnairi/rollup-plugin-create-html";

createHtml({
name: "index.html"
});

createHtml({
name: "404.html"
});

createHtml({
name: "200.html"
});
```

### Path

The path to the file to generate. This should not include any file name nor absolute nor relative paths.

```javascript
import { createHtml } from "@aminnairi/rollup-plugin-create-html";

createHtml({
path: "."
});

createHtml({
path: "pages"
});

createHtml({
name: "assets/html"
});
```

### Doctype

The doctype for the generated file.

```javascript
import { createHtml } from "@aminnairi/rollup-plugin-create-html";

createHtml({
doctype: ""
});

createHtml({
doctype: ``
});
```

### Root

The HTML content of the document to generate.

```javascript
import { createHtml } from "@aminnairi/rollup-plugin-create-html";

createHtml({
name: "index.html",
path: ".",
doctype: "",
root: {
name: "html"
}
});
```

```html

```

```javascript
createHtml({
name: "index.html",
path: ".",
doctype: "",
//
root: {
name: "html",
children: []
}
});
```

```html

```

```javascript
createHtml({
name: "index.html",
path: ".",
doctype: "",
//
root: {
name: "html",
attributes: {
lang: "en-US",
dir: "ltr"
},
children: []
}
});
```

```html

```

```javascript
createHtml({
name: "index.html",
path: ".",
doctype: "",
// HTML
root: {
name: "html",
children: [
"HTML"
]
}
});
```

```html

HTML

```

```javascript
createHtml({
name: "index.html",
path: ".",
doctype: "",
//
root: {
name: "html",
children: [
{
name: "body",
children: [
{
name: "div",
attributes: {
id: "root"
},
children: []
}
{
name: "script",
attributes: {
src: "index.js",
async: true,
defer: false
},
children: []
}
]
}
]
}
});
```

```html




```