@rollup/plugin-html
Advanced tools
Comparing version 1.0.5 to 1.1.0
@@ -24,4 +24,4 @@ 'use strict'; | ||
}; | ||
const defaultTemplate = async ({ attributes, files, meta, publicPath, title }) => { | ||
const scripts = (files.js || []) | ||
const defaultTemplate = async ({ attributes, files, meta, publicPath, title, addScriptsToHead }) => { | ||
let scripts = (files.js || []) | ||
.map(({ fileName }) => { | ||
@@ -32,3 +32,3 @@ const attrs = makeHtmlAttributes(attributes.script); | ||
.join('\n'); | ||
const links = (files.css || []) | ||
let links = (files.css || []) | ||
.map(({ fileName }) => { | ||
@@ -39,2 +39,6 @@ const attrs = makeHtmlAttributes(attributes.link); | ||
.join('\n'); | ||
if (addScriptsToHead === true) { | ||
links += scripts; | ||
scripts = ''; | ||
} | ||
const metas = meta | ||
@@ -70,6 +74,7 @@ .map((input) => { | ||
template: defaultTemplate, | ||
title: 'Rollup Bundle' | ||
title: 'Rollup Bundle', | ||
addScriptsToHead: false | ||
}; | ||
function html(opts = {}) { | ||
const { attributes, fileName, meta, publicPath, template, title } = Object.assign({}, defaults, opts); | ||
const { addScriptsToHead, attributes, fileName, meta, publicPath, template, title } = Object.assign({}, defaults, opts); | ||
return { | ||
@@ -89,2 +94,3 @@ name: 'html', | ||
attributes, | ||
addScriptsToHead, | ||
bundle, | ||
@@ -91,0 +97,0 @@ files, |
@@ -24,4 +24,4 @@ 'use strict'; | ||
}; | ||
const defaultTemplate = async ({ attributes, files, meta, publicPath, title }) => { | ||
const scripts = (files.js || []) | ||
const defaultTemplate = async ({ attributes, files, meta, publicPath, title, addScriptsToHead }) => { | ||
let scripts = (files.js || []) | ||
.map(({ fileName }) => { | ||
@@ -32,3 +32,3 @@ const attrs = makeHtmlAttributes(attributes.script); | ||
.join('\n'); | ||
const links = (files.css || []) | ||
let links = (files.css || []) | ||
.map(({ fileName }) => { | ||
@@ -39,2 +39,6 @@ const attrs = makeHtmlAttributes(attributes.link); | ||
.join('\n'); | ||
if (addScriptsToHead === true) { | ||
links += scripts; | ||
scripts = ''; | ||
} | ||
const metas = meta | ||
@@ -70,6 +74,7 @@ .map((input) => { | ||
template: defaultTemplate, | ||
title: 'Rollup Bundle' | ||
title: 'Rollup Bundle', | ||
addScriptsToHead: false | ||
}; | ||
function html(opts = {}) { | ||
const { attributes, fileName, meta, publicPath, template, title } = Object.assign({}, defaults, opts); | ||
const { addScriptsToHead, attributes, fileName, meta, publicPath, template, title } = Object.assign({}, defaults, opts); | ||
return { | ||
@@ -89,2 +94,3 @@ name: 'html', | ||
attributes, | ||
addScriptsToHead, | ||
bundle, | ||
@@ -91,0 +97,0 @@ files, |
@@ -20,4 +20,4 @@ import { extname } from 'path'; | ||
}; | ||
const defaultTemplate = async ({ attributes, files, meta, publicPath, title }) => { | ||
const scripts = (files.js || []) | ||
const defaultTemplate = async ({ attributes, files, meta, publicPath, title, addScriptsToHead }) => { | ||
let scripts = (files.js || []) | ||
.map(({ fileName }) => { | ||
@@ -28,3 +28,3 @@ const attrs = makeHtmlAttributes(attributes.script); | ||
.join('\n'); | ||
const links = (files.css || []) | ||
let links = (files.css || []) | ||
.map(({ fileName }) => { | ||
@@ -35,2 +35,6 @@ const attrs = makeHtmlAttributes(attributes.link); | ||
.join('\n'); | ||
if (addScriptsToHead === true) { | ||
links += scripts; | ||
scripts = ''; | ||
} | ||
const metas = meta | ||
@@ -66,6 +70,7 @@ .map((input) => { | ||
template: defaultTemplate, | ||
title: 'Rollup Bundle' | ||
title: 'Rollup Bundle', | ||
addScriptsToHead: false | ||
}; | ||
function html(opts = {}) { | ||
const { attributes, fileName, meta, publicPath, template, title } = Object.assign({}, defaults, opts); | ||
const { addScriptsToHead, attributes, fileName, meta, publicPath, template, title } = Object.assign({}, defaults, opts); | ||
return { | ||
@@ -85,2 +90,3 @@ name: 'html', | ||
attributes, | ||
addScriptsToHead, | ||
bundle, | ||
@@ -87,0 +93,0 @@ files, |
{ | ||
"name": "@rollup/plugin-html", | ||
"version": "1.0.5", | ||
"version": "1.1.0", | ||
"publishConfig": { | ||
@@ -5,0 +5,0 @@ "access": "public" |
@@ -51,2 +51,9 @@ [npm]: https://img.shields.io/npm/v/@rollup/plugin-html | ||
### `addScriptsToHead` | ||
Type: `Boolean`<br> | ||
Default: `false` | ||
Place scripts in the `<head>` tag instead of `<body>`. | ||
### `attributes` | ||
@@ -53,0 +60,0 @@ |
import type { Plugin, OutputChunk, OutputAsset, OutputBundle } from 'rollup'; | ||
export interface RollupHtmlTemplateOptions { | ||
title: string; | ||
addScriptsToHead?: boolean; | ||
attributes: Record<string, any>; | ||
publicPath: string; | ||
meta: Record<string, any>[]; | ||
bundle: OutputBundle; | ||
files: Record<string, (OutputChunk | OutputAsset)[]>; | ||
meta: Record<string, any>[]; | ||
publicPath: string; | ||
title: string; | ||
} | ||
export interface RollupHtmlOptions { | ||
title?: string; | ||
addScriptsToHead?: boolean; | ||
attributes?: Record<string, any>; | ||
@@ -19,2 +20,3 @@ fileName?: string; | ||
template?: (templateoptions: RollupHtmlTemplateOptions) => string | Promise<string>; | ||
title?: string; | ||
} | ||
@@ -21,0 +23,0 @@ |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
19630
343
168