webpack-plugin-buildinfo
TypeScript icon, indicating that this package has built-in type declarations

0.3.1 • Public • Published

webpack-buildinfo

Webpack buildinfo is a Webpack loader that injects build information into code.

Table of Contents

Installation

yarn add -D webpack-plugin-buildinfo # yarn (recommended)

npm install --save-dev webpack-plugin-buildinfo # npm

Usage

ES6 Modules:

import buildinfo from "!webpack-plugin-buildinfo?gitHashShort&time!";

Node.JS require:

const buildinfo = require("!webpack-plugin-buildinfo?gitHashShort&time!");

You can then use the buildinfo object like so:

console.log(
    `MyCoolProject v${buildinfo.gitHashShort} compiled at ${new Date(
        buildinfo.time
    ).toISOString()}`
);

Configuration

Change the import string with the flags to set. E.g. "!webpack-plugin-buildinfo?flag1&flag2&flag3!"

For more up to date information see the source code.

esModule

Type: boolean
Default: true
Description: Whether or not to use ES6 module syntax for output (i.e. export default instead of module.exports =)

all

Type: boolean
Default: false
Description: Override to enable all of the below flags.

The following flags are all booleans, with a default of false.

Name Description Example
gitHash Full git hash of the current commit, as of build time. This is the hash of your project. "46030d85f6f1f1eaf62578e410e8cd83ddbcc28c"
gitHashShort Same as above, but only the first 7 letters/numbers. "46030d8"
time The number of milliseconds elapsed since January 1, 1970 00:00:00 UTC. 1605960299010
platform OS Platform "win32"
arch OS Arch "x64"
cpus Array of all the cpus See documentation
hostname Computer hostname "Computer1234"
freemem The amount of free system memory in bytes as an integer. 18772148224
totalmem The total amount of system memory in bytes as an integer. 34274238464
userInfo An object containing the uid, gid, shell, homedir, and username of the current user. See documentation
networkInterfaces An array of all the network interfaces. See documentation
webpackVersion Webpack version "5.6.0"
nodeVersion Node.js version "12.19.0"
npmVersion npm version "6.14.8"
yarnVersion Yarn version "2.3.3"

Readme

Keywords

none

Package Sidebar

Install

npm i webpack-plugin-buildinfo

Weekly Downloads

12

Version

0.3.1

License

Apache-2.0

Unpacked Size

22.3 kB

Total Files

6

Last publish

Collaborators

  • sportshead