@rollup/plugin-html
Advanced tools
Comparing version 0.1.1 to 0.2.0
# @rollup/plugin-html ChangeLog | ||
## v0.2.0 | ||
_2020-05-02_ | ||
### Features | ||
- feat: support custom meta element creation (#308) | ||
### Updates | ||
- test: update snapshots for rollup v2 (c09509f) | ||
## v0.1.1 | ||
@@ -4,0 +16,0 @@ |
@@ -5,3 +5,3 @@ const { extname } = require('path'); | ||
const files = Object.values(bundle).filter( | ||
(file) => file.isEntry || file.type === 'asset' || file.isAsset | ||
(file) => file.isEntry || (typeof file.type === 'string' ? file.type === 'asset' : file.isAsset) | ||
); | ||
@@ -28,3 +28,3 @@ const result = {}; | ||
const defaultTemplate = async ({ attributes, files, publicPath, title }) => { | ||
const defaultTemplate = async ({ attributes, files, meta, publicPath, title }) => { | ||
const scripts = (files.js || []) | ||
@@ -44,2 +44,9 @@ .map(({ fileName }) => { | ||
const metas = meta | ||
.map((input) => { | ||
const attrs = makeHtmlAttributes(input); | ||
return `<meta${attrs}>`; | ||
}) | ||
.join('\n'); | ||
return ` | ||
@@ -49,3 +56,3 @@ <!doctype html> | ||
<head> | ||
<meta charset="utf-8"> | ||
${metas} | ||
<title>${title}</title> | ||
@@ -69,2 +76,3 @@ ${links} | ||
fileName: 'index.html', | ||
meta: [{ charset: 'utf-8' }], | ||
publicPath: '', | ||
@@ -76,3 +84,8 @@ template: defaultTemplate, | ||
const html = (opts = {}) => { | ||
const { attributes, fileName, publicPath, template, title } = Object.assign({}, defaults, opts); | ||
const { attributes, fileName, meta, publicPath, template, title } = Object.assign( | ||
{}, | ||
defaults, | ||
opts | ||
); | ||
return { | ||
@@ -97,3 +110,3 @@ name: 'html', | ||
const files = getFiles(bundle); | ||
const source = await template({ attributes, bundle, files, publicPath, title }); | ||
const source = await template({ attributes, bundle, files, meta, publicPath, title }); | ||
@@ -100,0 +113,0 @@ const htmlFile = { |
{ | ||
"name": "@rollup/plugin-html", | ||
"version": "0.1.1", | ||
"version": "0.2.0", | ||
"publishConfig": { | ||
@@ -11,3 +11,3 @@ "access": "public" | ||
"author": "Andrew Powell <andrew@shellscape.org>", | ||
"homepage": "https://github.com/rollup/plugins/tree/master/packages/beep", | ||
"homepage": "https://github.com/rollup/plugins/tree/master/packages/html#readme", | ||
"bugs": "https://github.com/rollup/plugins/issues", | ||
@@ -25,3 +25,3 @@ "main": "lib/index.js", | ||
"lint:docs": "prettier --single-quote --write *.md", | ||
"lint:js": "eslint --fix --cache lib test", | ||
"lint:js": "eslint --fix --cache lib test --ext .js,.ts", | ||
"lint:package": "prettier --write package.json --plugin=prettier-plugin-package", | ||
@@ -43,6 +43,6 @@ "prepublishOnly": "pnpm run lint", | ||
"peerDependencies": { | ||
"rollup": "^1.20.0" | ||
"rollup": "^1.20.0||^2.0.0" | ||
}, | ||
"devDependencies": { | ||
"rollup": "^1.27.5", | ||
"rollup": "^2.0.0", | ||
"rollup-plugin-postcss": "^2.0.3" | ||
@@ -49,0 +49,0 @@ }, |
@@ -65,2 +65,9 @@ [npm]: https://img.shields.io/npm/v/@rollup/plugin-html | ||
### `meta` | ||
Type: `Array[...object]`<br> | ||
Default: `[{ charset: 'utf-8' }]` | ||
Specifies attributes used to create `<meta>` elements. For each array item, provide an object with key-value pairs that represent `<meta>` element attribute names and values. | ||
Specifies the name of the HTML to emit. | ||
@@ -99,3 +106,3 @@ | ||
<head> | ||
<meta charset="utf-8" /> | ||
${metas} | ||
<title>${title}</title> | ||
@@ -102,0 +109,0 @@ ${links} |
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
11387
101
161