# webpack-hot-release

> spa hot release with webpack

Latest version **0.0.7** (published 2020-03-11) · 0 weekly downloads

## Install

```sh
npm install webpack-hot-release
pnpm add webpack-hot-release
yarn add webpack-hot-release
bun add webpack-hot-release
```

## Health

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

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support; low quality score; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.0.7 |
| Published | 2020-03-11 |
| First published | 2019-09-06 |
| Weekly downloads | 0 |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 2 |
| Unpacked size | 24.9 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 0 |
| Maintainers | flynnlee123 |

## Links

- npm: https://www.npmjs.com/package/webpack-hot-release
- Repository: https://github.com/FlynnLeeGit/webpack-hot-release
- Issues: https://github.com/FlynnLeeGit/webpack-hot-release/issues
- npm.io page: https://npm.io/package/webpack-hot-release

## Dependencies (2)

- [chalk](https://npm.io/package/chalk.md) ^2.4.2
- [git-rev-sync](https://npm.io/package/git-rev-sync.md) ^1.12.0

## Recent versions

- 0.0.7 (latest) — 2020-03-11
- 0.0.6 — 2020-03-11
- 0.0.5 — 2020-02-18
- 0.0.4 — 2020-02-13
- 0.0.2 — 2019-09-06
- 0.0.1 — 2019-09-06

## README

# webpack-hot-release

single page application hot release with webpack && git

webpack.config.js

- should use git
- should use history mode with spa router

```js
const WebpackHotReleasePlugin = require("webpack-hot-release/plugin");

{
  plugins: [new WebpackHotReleasePlugin()];
}
```

browser

```js
/**
 * first script
 **/

import "./hot-release.js";
```

hot-release.js

```js
import hotRelease from "webpack-hot-release/client";

hotRelease({
  // how long to check update
  throttle: 20,
  // baseUrl to fetch release.json when you use subPath,it's useful
  baseUrl: "/",
  // default git message on screen，can pass html tag
  gitHtml({ message, commit, date }) {
    return `${commit} ${message} ${date}`;
  }
});
```

### How it works?

1. webpack produce release.json in dist folder, like this,it will always the newest relase file

```json
{
  "NODE_ENV": "production",
  "GIT_COMMIT": "a9a834e",
  "GIT_MESSAGE": "test",
  "GIT_BRANCH": "master",
  "GIT_DATE": "2019-09-06T09:02:24.000Z"
}
```

2. webpack.DefinePlugin() to Define GIT args

```
'process.env.GIT_COMMIT'
'process.env.GIT_BRANCH'
'process.env.GIT_MESSAGE'
'process.env.GIT_DATE'
```

3. in client browser,it overriade pushState && replaceState function,make a request to fetch 'release.json'

4. in production it will 'location.reload()',in development,just output message

---
_Source: https://npm.io/package/webpack-hot-release · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
