webpack-compiler-plugin
TypeScript icon, indicating that this package has built-in type declarations

1.1.5 • Public • Published

Webpack Compiler Plugin

Build Status Coverage Status npm version Dependencies Dependabot badge

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
        }),
    ],
};

Package Sidebar

Install

npm i webpack-compiler-plugin

Weekly Downloads

694

Version

1.1.5

License

Unlicense

Unpacked Size

19.5 kB

Total Files

9

Last publish

Collaborators

  • iamogbz