https://github.com/iamogbz/webpack-compiler-plugin
🏗️ Easily listen to webpack compiler hooks and execute commands on events
https://github.com/iamogbz/webpack-compiler-plugin
shell-plugin webpack webpack-command webpack-compile webpack-plugin webpack-shell webpack4
Last synced: 12 months ago
JSON representation
🏗️ Easily listen to webpack compiler hooks and execute commands on events
- Host: GitHub
- URL: https://github.com/iamogbz/webpack-compiler-plugin
- Owner: iamogbz
- License: unlicense
- Created: 2019-06-27T02:55:48.000Z (almost 7 years ago)
- Default Branch: master
- Last Pushed: 2024-09-30T10:15:31.000Z (over 1 year ago)
- Last Synced: 2025-04-29T16:07:30.292Z (12 months ago)
- Topics: shell-plugin, webpack, webpack-command, webpack-compile, webpack-plugin, webpack-shell, webpack4
- Language: TypeScript
- Homepage: http://ogbizi.com/webpack-compiler-plugin/
- Size: 138 MB
- Stars: 2
- Watchers: 2
- Forks: 1
- Open Issues: 7
-
Metadata Files:
- Readme: README.md
- Contributing: CONTRIBUTING.md
- License: LICENSE
- Code of conduct: CODE_OF_CONDUCT.md
- Codeowners: .github/CODEOWNERS
Awesome Lists containing this project
README
# Webpack Compiler Plugin
[](https://github.com/iamogbz/webpack-compiler-plugin/actions?query=workflow%3ABuild)
[](https://coveralls.io/github/iamogbz/webpack-compiler-plugin)
[](https://badge.fury.io/js/webpack-compiler-plugin)
[](https://github.com/iamogbz/webpack-compiler-plugin)
[](https://app.dependabot.com)
Easily listen to `webpack` compiler hooks and execute commands on events.
## API
This plugin runs your specified commands at keys stages in the `webpack` build process.
### `buildStart`
This is run only once when the `webpack` build is first started, just after plugin are loaded.
See [webpack.compiler.hook.afterPlugins](https://webpack.js.org/api/compiler-hooks/#afterplugins).
### `compileStart`
This is run every time `webpack` starts compiling the source code, can be run multiple times when using the `--watch` flag.
See [webpack.compiler.hook.compilation](https://webpack.js.org/api/compiler-hooks/#compilation).
### `compileEnd`
This is run every time `webpack` finishes compiling the source code, just after the code is emitted.
See [webpack.compiler.hook.done](https://webpack.js.org/api/compiler-hooks/#done).
### `buildEnd`
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.
See [node.process.exit](https://nodejs.org/api/process.html#process_event_exit).
## Example
```js
/* webpack.config.js */
const { execSync } = require("child_process");
const { WebpackCompilerPlugin } = require("webpack-compiler-plugin");
module.exports = {
mode: "development",
plugins: [
new WebpackCompilerPlugin({
name: "my-compile-plugin",
listeners: {
buildStart: () => execSync("echo 'hello'"),
buildEnd: () => execSync("echo 'bye bye'"),
},
stageMessages: null, // to disable stage messages
}),
],
};
```