Skip to content

Commit 6294c0f

Browse files
committed
docs: add usage information
1 parent ee555b6 commit 6294c0f

File tree

4 files changed

+117
-71
lines changed

4 files changed

+117
-71
lines changed

.nvmrc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
stable

README.md

Lines changed: 44 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -5,26 +5,54 @@
55
[![Build Status](https://travis-ci.org/iamogbz/webpack-compiler-plugin.svg?branch=master)](https://travis-ci.org/iamogbz/webpack-compiler-plugin)
66
[![Coverage Status](https://coveralls.io/repos/github/iamogbz/webpack-compiler-plugin/badge.svg?branch=master)](https://coveralls.io/github/iamogbz/webpack-compiler-plugin?branch=master)
77

8-
Easily listen to webpack compiler hooks and execute commands on events
8+
Easily listen to `webpack` compiler hooks and execute commands on events.
99

10-
## Shell Commands
10+
## API
1111

12-
```sh
13-
npm run test # run jest tests
14-
```
12+
This plugin runs your specified commands at keys stages in the `webpack` build process.
1513

16-
```sh
17-
npm run commit # run commitizen
18-
```
14+
### `buildStart`
1915

20-
```sh
21-
npm run build # webpack build
22-
```
16+
This is run only once when the `webpack` build is first started, just after plugin are loaded.
2317

24-
### Typescript
18+
See [webpack.compiler.hook.afterPlugins](https://webpack.js.org/api/compiler-hooks/#afterplugins).
2519

26-
```sh
27-
make typescript
28-
```
20+
### `compileStart`
21+
22+
This is run every time `webpack` starts compiling the source code, can be run multiple times when using the `--watch` flag.
23+
24+
See [webpack.compiler.hook.compilation](https://webpack.js.org/api/compiler-hooks/#compilation).
25+
26+
### `compileEnd`
27+
28+
This is run every time `webpack` finishes compiling the source code, just after the code is emitted.
2929

30-
[Example conversion](https://github.com/iamogbz/node-js-boilerplate/compare/typescript-conversion)
30+
See [webpack.compiler.hook.done](https://webpack.js.org/api/compiler-hooks/#done).
31+
32+
### `buildEnd`
33+
34+
This is the last stage run only when the build process is exiting. Is also triggered when exiting is caused by a build failure, interrupt signal, etc.
35+
36+
See [node.process.exit](https://nodejs.org/api/process.html#process_event_exit).
37+
38+
## Example
39+
40+
```js
41+
/* webpack.config.js */
42+
43+
const { execSync } = require("child_process");
44+
const { WebpackCompilerPlugin } = require("webpack-compile-plugin");
45+
46+
module.exports = {
47+
mode: "development",
48+
plugins: [
49+
new WebpackCompilerPlugin({
50+
name: "my-compile-plugin",
51+
listeners: {
52+
buildStart: () => execSync("echo 'hello'"),
53+
buildEnd: () => execSync("echo 'bye bye'"),
54+
},
55+
}),
56+
],
57+
};
58+
```

package-lock.json

Lines changed: 71 additions & 55 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,7 @@
9191
"@commitlint/cli": "^8.0.0",
9292
"@commitlint/config-conventional": "^8.0.0",
9393
"@commitlint/travis-cli": "^8.0.0",
94+
"@semantic-release/github": "^5.4.0",
9495
"@types/chrome": "0.0.81",
9596
"@types/copy-webpack-plugin": "^4.4.3",
9697
"@types/jest": "^24.0.9",

0 commit comments

Comments
 (0)