npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@allroundexperts/run-node-webpack-plugin

v1.0.0

Published

Webpack plugin that starts a node.js script after webpack compilation and smartly restarts it after subsequent recompilations

Downloads

8

Readme

Run Node Webpack Plugin

Webpack plugin that starts a node.js script after webpack compilation and smartly restarts it after subsequent recompilations

Installation

$ npm install run-node-webpack-plugin --save-dev

Usage

webpack.config.js

const RunNodeWebpackPlugin = require('run-node-webpack-plugin');

module.exports = {
    // ...
    plugins: [
        new RunNodeWebpackPlugin()
    ],
    // ...
};

Plugin's primary use case is when you are developing a node.js app with webpack and want that app to restart whenever webpack finishes compiling its bundle.

Advantages

  • More efficient in webpack development scenarios than nodemon, pm2, forever, etc.
  • Contrary to other similar plugins can restart script only when an actual change in webpack bundle occurs
  • Rich customization possible via plugin options

Options

All the options are optional and are configured so that in most cases you should not want to change them.

scriptToRun: string

Node script which will be run after webpack compilations. You can provide a file name from webpack output or path to an external file.

Default: By default when webpack config contains only one output file then that file will be run. If more files are present then file named server.js or index.js (whichever exists) will be run

Examples

// ...
entry: {
    server: 'src/server.js',
    otherScript: 'src/otherScript.js'
},
output: {
    path: 'build',
    filename: '[name].js'
},
// ...
plugins: [
    new RunNodeWebpackPlugin({ scriptToRun: 'otherScript.js' })
],
// ...

In this example by default server.js would be run but you can change it to otherScript.js.

// ...
entry: 'src/index.js',
output: {
    path: 'build',
    filename: 'webpackOutputScript.js'
},
// ...
plugins: [
    new RunNodeWebpackPlugin({ scriptToRun: './path/to/external/file.js' })
],
// ...

In this example by default webpackOutputScript.js would be run but you can change it to an external script not connected with webpack build process, for example: ./path/to/external/file.js.

// ...
entry: {
    server: 'src/server.js',
},
output: {
    path: 'build',
    filename: '[name].js'
},
// ...
plugins: [
    new RunNodeWebpackPlugin({
        scriptToRun: 'server.js',
        processArgs: {
            execArgv:['--inspect-brk']
        } 
    })
],
// ...

In this example a debugger is attached when running the script.

runOnlyOnChanges: boolean

When set to true plugin will run the script only when an actual change in webpack output files happens, otherwise after every webpack compilation.

Default: true

scriptsToWatch: string[]

Array of webpack ouput file names that plugin should watch for changes. Works only if runOnlyOnChanges is set to true.

Default: By default plugin watches all webpack output files

Examples

// ...
entry: {
    server: 'src/server.js',
    script: 'src/script.js'
},
output: {
    path: 'build',
    filename: '[name].js'
},
// ...
plugins: [
    new RunNodeWebpackPlugin({ scriptsToWatch: ['server.js'] })
],
// ...

In this example by default plugin would run server.js whenever a change to server.js or script.js happens but you can exclude script.js from change detection by providing only server.js to scriptsToWatch option.

runOnlyInWatchMode: boolean

When set to true plugin will run the script only when webpack is in a watch mode.

Default: false

runOnlyInNormalMode: boolean

When set to true plugin will run the script only when webpack is NOT in a watch mode.

Default: false

ignoreErrors: boolean

When set to true plugin will try to run the script even when webpack compilation throws errors.

Default: false

nodeArgs: string[]

List of string arguments to pass to the node script. See more information

Default: []

processArgs: Object

List of options to pass to the process executing the node script. See more information

Default: []

License

Copyright © 2018 rdoo. Released under the MIT license.