# before-build-webpack

> Webpack plugin that gives ability to add callback before build (or at any other event hook). Can stop compilation by condition.

Latest version **0.2.15** (published 2024-01-14) · MIT license · 0 weekly downloads

## Install

```sh
npm install before-build-webpack
pnpm add before-build-webpack
yarn add before-build-webpack
bun add before-build-webpack
```

## Health

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

Positive: no vulnerabilities.

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

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.2.15 |
| Published | 2024-01-14 |
| First published | 2016-11-08 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Unpacked size | 16.3 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 16 |
| Author | Sasha Koss |
| Maintainers | artemdudkin |
| Keywords | webpack, conditional, before build, pre build |

## Links

- npm: https://www.npmjs.com/package/before-build-webpack
- Repository: https://github.com/artemdudkin/before-build-webpack
- Homepage: https://github.com/artemdudkin/before-build-webpack#readme
- Issues: https://github.com/artemdudkin/before-build-webpack/issues
- npm.io page: https://npm.io/package/before-build-webpack

## Alternatives

- [raw-loader](https://npm.io/package/raw-loader.md) — 4.3M weekly downloads
- [plop](https://npm.io/package/plop.md) — 1.4M weekly downloads
- [webpack-deadcode-plugin](https://npm.io/package/webpack-deadcode-plugin.md) — 80.3K weekly downloads
- [@storybook/preact-vite](https://npm.io/package/@storybook/preact-vite.md) — 54.2K weekly downloads
- [vite-plugin-transform](https://npm.io/package/vite-plugin-transform.md) — 2.4K weekly downloads

## Recent versions

- 0.2.15 (latest) — 2024-01-14
- 0.2.14 — 2024-01-14
- 0.2.13 — 2022-10-22
- 0.2.12 — 2021-12-02
- 0.2.11 — 2021-01-20
- 0.2.9 — 2019-04-18
- 0.2.8 — 2019-02-19
- 0.2.7 — 2019-02-19
- 0.2.6 — 2019-01-04
- 0.2.5 — 2018-10-17
- 0.2.4 — 2018-10-16
- 0.2.3 — 2018-09-29
- 0.2.2 — 2018-09-26
- 0.2.1 — 2018-09-26
- 0.2.0 — 2018-09-26
- … 1 more at https://npm.io/package/before-build-webpack/versions

## README

# before-build-webpack

[Webpack](http://webpack.github.io/) (v1-5) plugin that gives ability to add callback
before build (or after, or any other [event hook](https://webpack.js.org/api/compiler-hooks/)). 
Can stop compilation by condition.

![tests status](https://github.com/artemdudkin/before-build-webpack/actions/workflows/node.js.yml/badge.svg)
[![NPM Downloads](https://img.shields.io/npm/dw/before-build-webpack)](https://img.shields.io/npm/dw/before-build-webpack)

## Installation

```
npm install --save-dev before-build-webpack
```

## Usage

In config file:

``` javascript
var WebpackBeforeBuildPlugin = require('before-build-webpack');
// ...
  module: {
    plugins: [
      new WebpackBeforeBuildPlugin(function(stats, callback) {
        // Do whatever you want...
        callback(); // don't call it if you do want to stop compilation
      }),
    ]
  },
// ...
```

## OR (more power)

``` javascript
// ...
  module: {
    plugins: [
      new WebpackBeforeBuildPlugin(function(stats, callback) {
        // ...
      }, ['run', 'watch-run', 'done']), // will fire before build and after build
    ]
  },
// ...
```
You can use [pre-v4](https://github.com/webpack/webpack.js.org/blob/v3.11.0/src/content/api/compiler.md#event-hooks) or [v4](https://webpack.js.org/api/compiler-hooks/) hook names (i.e. any of `watch-run` and `watchRun`)

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