1.0.0 • Published 2 years ago
esbuild-header v1.0.0
esbuild-header
This plugin lets you add a header comment to the top of your build with Esbuild
Installation
$ npm install --save-dev esbuild-header
Getting Started
main.js
const date = new Date();
const currentTime = `${date.getHours()}:${date.getMintues()}:${date.getSeconds()}`;
console.log(currentTimes);
build.js
const headerPlugin = require('esbuild-header');
require('esbuild').build({
entryPoints: ['main.js'],
bundle: true,
outfile: 'out.js',
plugins: [headerPlugin()],
});
out.js
/*!
* esbuild-header
* A Esbuild plugin to add a header to file(s) after build
* @author Johnie Hjelm <johnie@hjelm.im>
* @version 1.0.0
* Copyright 2022 MIT licensed.
*/
const date = new Date();
const currentTime = `${date.getHours()}:${date.getMintues()}:${date.getSeconds()}`;
console.log(currentTimes);
Configuration
An object containing configuration options may be passed into the plugin constructor headerPlugin
headerPlugin({
template: '// This is my header',
cwd: '/Users/foo/path/to/package.json',
});
The following options are available:
options.template
,string
: if specified, you can use your own header template with the use of Pupa to use data frompackage.json
.options.cwd
,string
: the path to a specifiedpackage.json
to parse data for header. Default is closest foundpackage.json
1.0.0
2 years ago