esbuild-plugin-hbs

0.0.3 • Public • Published

esbuild-plugin-hbs is a plugin to generate HTML files through handlebars with esbuild.

Is anything missing, please please create a ticket

Requirements

...

Installation

yarn add -D esbuild-plugin-hbs
# or
npm i --save-dev esbuild-plugin-hbs

Usage

You can set options in separate json files.

Some helpers are included out of the box. I will keep adding to the list.

You can use the json helper like the following code to debug your data.

{{ json user }}

Under the hood esbuild-plugin-hbs uses the jsdom lib.

⚠️ This plugin tries to cover most cases, set as much as possible with little configuration. If you find that I have forgotten certain issues, please write a ticket

Sample configuration

const options: {
	entryPoints: ['index.ts'],
	bundle: true,
	metafile: true,
	outdir: 'dist/',
	plugins: [
		handlebarsPlugin({
			views: 'views',
			html: 'html',
			public: 'public',
			files: [
				{
					filename: 'single.hbs',
					title: 'This is the Single file',
					data: './single.json',
				},
				{
					filename: 'about.html',
					title: 'This is the about file',
					data: './user.json',
				},
			]
		}),
	],
};

esbuild.build(options).catch(() => process.exit(1))

Sample json configuration

{
	"title": "This is the single page",
	"namespace": "single",
	"insertScript": true,
	"items": [{
		"id": 1,
		"first_name": "Kaila"
	}, {
		"id": 2,
		"first_name": "Barrie"
	}]
}

Contributing

Contributions are very welcome

Todos

Package Sidebar

Install

npm i esbuild-plugin-hbs

Weekly Downloads

20

Version

0.0.3

License

MIT

Unpacked Size

81.8 kB

Total Files

10

Last publish

Collaborators

  • derpiet