Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/artemdudkin/before-build-webpack
Webpack (v1-5) plugin that gives ability to add callback before build (or after, or at any other event hook). Can stop compilation by condition.
https://github.com/artemdudkin/before-build-webpack
Last synced: 2 months ago
JSON representation
Webpack (v1-5) plugin that gives ability to add callback before build (or after, or at any other event hook). Can stop compilation by condition.
- Host: GitHub
- URL: https://github.com/artemdudkin/before-build-webpack
- Owner: artemdudkin
- License: mit
- Fork: true (kossnocorp/on-build-webpack)
- Created: 2016-11-08T23:37:31.000Z (over 7 years ago)
- Default Branch: master
- Last Pushed: 2022-10-22T15:55:46.000Z (over 1 year ago)
- Last Synced: 2023-12-12T10:07:32.096Z (7 months ago)
- Language: JavaScript
- Homepage:
- Size: 28.3 KB
- Stars: 16
- Watchers: 2
- Forks: 3
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE.md
Lists
- fontawesome-autogen - before-build-webpack
- fontawesome-autoimport - before-build-webpack
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`)