README
snowpack-plugin-build-info
Snowpack plugin to show git / build info (Basicaly snowpack-plugin-replace but only for git info)
Usage
Install
1 Get the plugin
(Option 1) Local dev env: Link the project to an npm package: (budget npm registry)
- Navigate to the plugin project folder
$ npm link snowpack-plugin-build-info
(Option 2) Npm registry package (not yet):
npm: $ npm install --save-dev snowpack-plugin-build-info
yarn: $ yarn add -D snowpack-plugin-build-info
2 Add plugin to snowpack config
Add the plugin to the snowpack config file (e.g. snowpack.config.js
or snowpack.config.json
):
plugins: [
["snowpack-plugin-build-info", {
// ... pluginOptions
}]
],
The following pluginOptions are available:
| Option | Required | Description | Example |
| - | - | - | - |
| allowedExts | true | A list of file extensions where tag replacement is allowed to happen |allowedExts: ['.html', '.js', '.css']
|
Config
Add the desired tags to the HTML / JS / whatever:
<!-- In the head as meta tag: -->
<meta name="git-branch-name" content="%GIT_BRANCH_NAME%" />
<!-- Or in the main body: -->
<p>Git branch name: %GIT_BRANCH_NAME%</p>
Currently supported tags
Tag | Example result |
---|---|
%GIT_BRANCH_NAME% | master |
%GIT_COMMIT_HASH_LONG% | ae76d8e24aff8684504e53d281c102fbed2ab204 |
%GIT_COMMIT_HASH_SHORT% | ae76d8e |
%GIT_COMMIT_DATETIME% | 2020-11-21 19:58:14 |
%GIT_COMMIT_DATE% | 2020-11-21 |
%BUILD_DATETIME% | 2020-11-21 21:32:32 |
%BUILD_DATE% | 2020-11-21 |
%BUILD_ENV% | development |