# @springernature/util-package-renderer

> Renders a package that passes SN package validation

Latest version **3.3.1** (published 2022-09-20) · MIT license · 0 weekly downloads

## Install

```sh
npm install @springernature/util-package-renderer
pnpm add @springernature/util-package-renderer
yarn add @springernature/util-package-renderer
bun add @springernature/util-package-renderer
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 3.3.1 |
| Published | 2022-09-20 |
| First published | 2020-10-01 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 16 |
| Unpacked size | 408.9 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 0 |
| Author | jpw, ajk |
| Maintainers | roshandeorukhkar-sn, benjclark, sonniesedge, rlau, dotcode, joseluisbolos, hollsk, moddular, jpw, nickcall, howlingmad, sndigital, davidpauljunior, morgaan |
| Keywords | springernature |

## Links

- npm: https://www.npmjs.com/package/@springernature/util-package-renderer
- Repository: https://github.com/springernature/frontend-toolkit-utilities
- Homepage: https://github.com/springernature/frontend-toolkit-utilities#readme
- Issues: https://github.com/springernature/frontend-toolkit-utilities/issues
- npm.io page: https://npm.io/package/@springernature/util-package-renderer

## Dependencies (16)

- [sass](https://npm.io/package/sass.md) ^1.47.0
- [rollup](https://npm.io/package/rollup.md) ^2.42.0
- [cheerio](https://npm.io/package/cheerio.md) ^1.0.0-rc.10
- [filesize](https://npm.io/package/filesize.md) ^5.0.3
- [handlebars](https://npm.io/package/handlebars.md) ^4.4.3
- [@babel/core](https://npm.io/package/@babel/core.md) ^7.15.5
- [image-data-uri](https://npm.io/package/image-data-uri.md) ^2.0.1
- [@babel/preset-env](https://npm.io/package/@babel/preset-env.md) ^7.15.4
- [@rollup/plugin-babel](https://npm.io/package/@rollup/plugin-babel.md) ^5.3.0
- [rollup-plugin-terser](https://npm.io/package/rollup-plugin-terser.md) ^7.0.2
- [@rollup/plugin-commonjs](https://npm.io/package/@rollup/plugin-commonjs.md) ^20.0.0
- [@rollup/plugin-node-resolve](https://npm.io/package/@rollup/plugin-node-resolve.md) ^13.0.4
- [@springernature/brand-context](https://npm.io/package/@springernature/brand-context.md) ^3.2.4
- [@springernature/util-cli-reporter](https://npm.io/package/@springernature/util-cli-reporter.md) ^2.0.0
- [@springernature/util-dynamic-partial](https://npm.io/package/@springernature/util-dynamic-partial.md) 0.1.0
- [@springernature/util-package-installer](https://npm.io/package/@springernature/util-package-installer.md) ^0.4.0

## Alternatives

- [@luma.gl/experimental](https://npm.io/package/@luma.gl/experimental.md) — 77.1K weekly downloads
- [persona-harness](https://npm.io/package/persona-harness.md) — 4.7K weekly downloads
- [@tsparticles/effect-bubble](https://npm.io/package/@tsparticles/effect-bubble.md) — 4.6K weekly downloads
- [f3d](https://npm.io/package/f3d.md) — 730 weekly downloads
- [spark-html-motion](https://npm.io/package/spark-html-motion.md) — 298 weekly downloads

## Recent versions

- 3.3.1 (latest) — 2022-09-20
- 3.3.0 — 2022-09-16
- 3.2.0 — 2022-02-14
- 3.1.0 — 2022-01-25
- 3.0.1 — 2022-01-25
- 3.0.0 — 2022-01-11
- 2.2.2 — 2022-01-06
- 2.2.1 — 2022-01-06
- 2.2.0 — 2021-11-26
- 2.1.1 — 2021-11-26
- 2.1.0 — 2021-11-26
- 2.0.0 — 2021-10-26
- 1.0.1 — 2021-09-13
- 1.0.0 — 2021-09-10
- 0.0.4 — 2020-10-06
- … 3 more at https://npm.io/package/@springernature/util-package-renderer/versions

## README

# Package Renderer

Renders an Elements-compatible package into HTML with all resources inlined.  
Optionally write the result to disk as `index.html`.

> **NOTE**: As of `v3.0.0` this package works with `dart-sass`, for `node-sass` support please continue using `v2.2.2`

## Usage

```js
const renderer = require('@springernature/util-package-renderer');
await renderer(config);
```

### Config

| Parameter                       | Default Value                   | Type     | Required | Description                                              |
|---------------------------------|---------------------------------|----------|----------|----------------------------------------------------------|
| config.demoCodeFolder           | demo                          | String   | Yes      | Name of demo code folder within your package               |
| config.brandContext             | @springernature/brand-context | String   | Yes      | Name of the brand-context package on NPM                   |
| config.reportingLevel           | title                         | String   | Yes      | Amount of reporting for util-cli-reporter                  |
| config.dynamicTemplateLocation  | .                             | String   | Yes      | Where to start looking for dynamic handlebars templates    |
| config.minify                   | false                         | Boolean  | Yes      | Minify the JS and CSS output                               |
| config.packageRoot              | .                             | String   | Yes      | Path to the package to render                              |
| config.distFolderPath           | null                          | String   | No       | Path to where index.html should be written                 |

## Full examples

A working implementation can also be found in [`runner.js`](./__mocks__/runner.js).

### Using default config

```js
'use strict';
const renderer = require('@springernature/util-package-renderer');

// By default no distFolder is defined and the result is returned as a String
(async () => {
	try {
		const result = await renderer();
		console.log(result);
	} catch (error) {
		console.error(error);
	}
})();
```

### Return result as String, with config

```js
const path = require('path');
const renderer = require('@springernature/util-package-renderer');

const fulldir = path.resolve(__dirname, 'apackage');
const demoFolderName = 'demo';
const brandContext = '@springernature/brand-context';

(async () => {
	try {
		const result = await renderer({
			demoCodeFolder: demoFolderName,
			reportingLevel: 'title',
			dynamicTemplateLocation: './path/to/location'
			minify: true,
			packageRoot: fulldir,
			brandContext: brandContext
		});
		console.log(result);
	} catch (error) {
		console.error(error);
	}
})();
```

### Write result to disk, with config

```js
const path = require('path');
const renderer = require('@springernature/util-package-renderer');

const fulldir = path.resolve(__dirname, 'apackage');
const demoFolderName = 'demo';
const brandContext = '@springernature/brand-context';
const distFolder = path.join(fulldir, 'dist');

(async () => {
	try {
		await renderer({
			demoCodeFolder: demoFolderName,
			reportingLevel: 'title',
			dynamicTemplateLocation: './path/to/location'
			minify: true,
			packageRoot: fulldir,
			brandContext: brandContext,
			distFolderPath: distFolder
		});
	} catch (error) {
		console.error(error);
	}
})();
```

---
_Source: https://npm.io/package/@springernature/util-package-renderer · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
