Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/lamo2k123/daemon-command-webpack-plugin
Run and restart npm commands after emit file webpack builds
https://github.com/lamo2k123/daemon-command-webpack-plugin
appveyor es6 node node-js nodejs travis webpack webpack-plugin webpack2 yarn
Last synced: about 1 month ago
JSON representation
Run and restart npm commands after emit file webpack builds
- Host: GitHub
- URL: https://github.com/lamo2k123/daemon-command-webpack-plugin
- Owner: lamo2k123
- Created: 2016-07-20T21:45:07.000Z (over 8 years ago)
- Default Branch: master
- Last Pushed: 2020-10-24T13:34:50.000Z (about 4 years ago)
- Last Synced: 2024-09-27T22:20:53.362Z (about 2 months ago)
- Topics: appveyor, es6, node, node-js, nodejs, travis, webpack, webpack-plugin, webpack2, yarn
- Language: JavaScript
- Size: 73.2 KB
- Stars: 12
- Watchers: 2
- Forks: 2
- Open Issues: 4
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
## daemon-command-webpack-plugin
[![license](https://img.shields.io/github/license/mashape/apistatus.svg?maxAge=2592000&style=flat-square)][License]
[![travis](https://img.shields.io/travis/lamo2k123/daemon-command-webpack-plugin/master.svg?maxAge=2592000&style=flat-square)][Travis]
[![AppVeyor](https://img.shields.io/appveyor/ci/lamo2k123/daemon-command-webpack-plugin.svg?maxAge=2592000&style=flat-square)][appVeyor]
[![npm](https://img.shields.io/npm/dt/daemon-command-webpack-plugin.svg?maxAge=2592000&style=flat-square)][NPM]
[![npm](https://img.shields.io/npm/v/daemon-command-webpack-plugin.svg?maxAge=2592000&style=flat-square)][NPM]This is simple webpack plugin that monitors webpack events and start or restart npm/yarn command.
The main purpose of this plugin is to restart node process when webpack has finised rebuilding the source tree.
It is also possible to wait for the marker to make sure the process is finished doing the job (like starting the web server)## Installing as a package
Use NPM:
`npm i daemon-command-webpack-plugin -D` or `npm install daemon-command-webpack-plugin --save-dev`Use YARN:
`yarn add daemon-command-webpack-plugin --dev`
## Usage
```javascript
// package.json{
"name": "me-app",
"version": "1.0.0",
"scripts": {
"start:dev:env": "node server/build/index.js",
"start:dev": "NODE_ENV=development PORT=3000 node server/build/index.js",
},
}
``````javascript
// webpack.config.jsimport DaemonCommandPlugin from 'daemon-command-webpack-plugin';
module.exports = {
// ... rest of config
plugins: [
// Command #1
new DaemonCommandPlugin('start:dev:env', {
spawn : {
env : {
NODE_ENV : 'development',
PORT : 3000
}
}
}),
// Command #2
new DaemonCommandPlugin('start:dev');,
// Command #3 use yarn
new DaemonCommandPlugin('start:dev', {
manager : 'yarn'
});
]
}
```
## Usage with marker
```javascript
// webpack.config.jsimport DaemonCommandPlugin from 'daemon-command-webpack-plugin';
module.exports = {
// ... rest of config
plugins: [
// Command #1
new DaemonCommandPlugin('start:dev', {
marker : true
});
]
}
``````javascript
// your-app.jsimport express from 'express';
import marker from 'daemon-command-webpack-plugin/marker';let app = express();
app.listen(8080, () => {
console.log('Listen port: 8080');
marker();
// or
marker('Listen port: 8080'); // Custom message
})
```## Arguments
* `command` [\][String] The package.json scripts command to run
* `options` [\][Object]
* `event` [\][String] Webpack life cycle event. Default: `after-emit`
* `marker` [\][Boolean] Resolve promise when a marker is found to stdout. Default: `false`
* `spawn` [\][Object] Spawn options
* `cwd` [\][String] Current working directory of the child process
* `env` [\][Object] Environment key-value pairs
* `argv0` [\][String] Explicitly set the value of argv[0] sent to the child process. This will be set to command if not specified.
* `stdio` [\][Array] | [\][String] Child's stdio configuration. (See options.stdio)
* `detached` [\][Boolean] Prepare child to run independently of its parent process. Specific behavior depends on the platform, see options.detached)
* `uid` [\][Number] Sets the user identity of the process
* `gid` [\][Number] Sets the group identity of the process
* `shell` [\][Boolean] | [\][String] If true, runs command inside of a shell. Uses `/bin/sh` on UNIX, and `cmd.exe` on Windows. A different shell can be specified as a string. The shell should understand the -c switch on UNIX, or /d /s /c on Windows. Defaults to false (no shell).Use `cwd` to specify the working directory from which the process is spawned. If not given, the default is to inherit the current working directory.
Use `env` to specify environment variables that will be visible to the new process, the default is process.env.## Marker arguments
* `out` [\][String] | [\][Array] Your custom message## License
[MIT][License][License]: http://www.opensource.org/licenses/mit-license.php
[NPM]: https://www.npmjs.com/package/daemon-command-webpack-plugin
[Travis]: https://travis-ci.org/lamo2k123/daemon-command-webpack-plugin
[appVeyor]: https://ci.appveyor.com/project/lamo2k123/daemon-command-webpack-plugin[String]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#String_type
[Object]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object
[Number]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#Number_type
[Boolean]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#Boolean_type
[Array]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array