webpack-compiler-plugin
v1.1.5
Published
Easily listen to webpack compiler hooks and execute commands on events
Downloads
2,016
Readme
Webpack Compiler Plugin
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.
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.
compileEnd
This is run every time webpack
finishes compiling the source code, just after the code is emitted.
See webpack.compiler.hook.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.
Example
/* 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
}),
],
};