Important: This documentation covers Yarn 1 (Classic).
For Yarn 2+ docs and migration guide, see yarnpkg.com.

Package detail

nodemon-webpack-plugin

Izhaki315.1kMIT4.8.2TypeScript support: included

A webpack plugin that starts and reloads a server using Nodemon.

webpack, nodemon, plugin, server, start, watch, restart

readme

Nodemon Webpack Plugin

GitHub Workflow Status

Uses Nodemon to watch and restart your module's output file (presumably a server), but only when webpack is in watch mode (ie, --watch).

Saves the need for installing, configuring and running Nodemon as a separate process.

Installation

npm install nodemon-webpack-plugin --save-dev

Usage

const NodemonPlugin = require('nodemon-webpack-plugin'); // Ding

module.exports = {
  entry: './src/server.js',
  output: {
    path: path.resolve('./dist'),
    filename: 'server.js',
  },
  plugins: [
    new NodemonPlugin(), // Dong
  ],
};

Then:

$ webpack --watch

Modes

Zero-config mode

new NodemonPlugin();

Will watch and restart the output file.

With config

Provide a Nodemon config object, like so:

new NodemonPlugin({
  // If using more than one entry, you can specify
  // which output file will be restarted.
  script: './dist/server.js',

  // What to watch.
  watch: path.resolve('./dist'),

  // Arguments to pass to the script being watched.
  args: ['demo'],

  // Node arguments.
  nodeArgs: ['--debug=9222'],

  // Files to ignore.
  ignore: ['*.js.map'],

  // Extensions to watch.
  ext: 'js,njk,json',

  // Unlike the cli option, delay here is in milliseconds (also note that it's a string).
  // Here's 1 second delay:
  delay: '1000',

  // Detailed log.
  verbose: true,

  // Environment variables to pass to the script to be restarted
  env: {
    NODE_ENV: 'development',
  },
});

For a full list of options, see Nodemon's type definitions (Settings interface).

changelog

4.8.2 (2023-10-10)

Bug Fixes

  • bump nodemon from 2.0.19 to 3.0.1 (33f60d5)

4.8.1 (2022-07-11)

Bug Fixes

  • bump nodemon from 2.0.16 to 2.0.19 (922cd89)

4.8.0 (2022-06-17)

Features

4.7.1 (2022-02-03)

Bug Fixes

  • Typescript error with "noImplicitAny" (071385c), closes #141

4.7.0 (2021-11-29)

Features