Skip to content

Commit

Permalink
- add ts support
Browse files Browse the repository at this point in the history
- add onBeforeBuild and onBuildExit
- add logging, swallowError, dev
  • Loading branch information
s00d committed Oct 16, 2019
1 parent 88c8b35 commit 5744ebc
Show file tree
Hide file tree
Showing 18 changed files with 5,751 additions and 8,460 deletions.
12 changes: 2 additions & 10 deletions .babelrc
Original file line number Diff line number Diff line change
@@ -1,13 +1,5 @@
{
"presets": [
[
"env",
{
"modules": false
}
]
],
"plugins": [
"external-helpers"
"@babel/preset-env"
]
}
}
207 changes: 0 additions & 207 deletions .eslintrc.json

This file was deleted.

71 changes: 34 additions & 37 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,13 @@ This plugin is meant for running simple command line executions. It is not meant
In `webpack.config.js`:

```js
const WebpackShellPlugin = require('webpack-shell-plugin-next');
const WebpackShellPluginNext = require('webpack-shell-plugin-next');

module.exports = {
...
...
plugins: [
new WebpackShellPlugin({
new WebpackShellPluginNext({
onBuildStart:{
scripts: ['echo "Webpack Start"'],
blocking: true,
Expand All @@ -43,48 +43,35 @@ module.exports = {
```

### API

* `onBeforeBuild`: array of scripts to execute before every build.
**Default: ```{scripts: [],blocking: false,parallel: false}```**
* `onBuildError`: array of scripts to execute when there is an error during compilation. **Default: [ ]**
**Default: ```{scripts: [],blocking: false,parallel: false}```**
* `onBuildStart`: configuration object for scripts that execute before a compilation.
**Default:**
```js
{
scripts: [],
blocking: false,
parallel: false
}
```
**Default: ```{scripts: [],blocking: false,parallel: false}```**
* `onBuildEnd`: configuration object for scripts that execute after files are emitted at the end of the compilation.
**Default:**
```js
{
scripts: [],
blocking: false,
parallel: false
}
```
**Default: ```{scripts: [],blocking: false,parallel: false}```**
* `onBuildExit`: configuration object for scripts that execute after webpack's process is complete. *Note: this event also fires in `webpack --watch` when webpack has finished updating the bundle.*
**Default:**
```js
{
scripts: [],
blocking: false,
parallel: false
}
```
* `blocking (onBuildStart, onBuildEnd, onBuildExit)`: block webpack until scripts finish execution.
* `parallel (onBuildStart, onBuildEnd, onBuildExit)`: execute scripts in parallel, otherwise execute scripts in the order in which they are specified in the scripts array.
**Default: ```{scripts: [],blocking: false,parallel: false}```**

**Note:** below combination is not supported.
```js
{
blocking: true
parallel: true
}
```

* `blocking (onBeforeBuild, onBuildStart, onBuildEnd, onBuildExit, onBuildExit)`: block webpack until scripts finish execution.
* `parallel (onBeforeBuild, onBuildStart, onBuildEnd, onBuildExit, onBuildExit)`: execute scripts in parallel, otherwise execute scripts in the order in which they are specified in the scripts array.
* `env`: Object with environment variables that will be applied to the executables **Default: { }**
* `logging`: show output for internal messages. **Default: true**
* `swallowError`: ignore script errors (useful in watch mode) **Default: false**
* `dev`: switch for development environments. This causes scripts to execute once. Useful for running HMR on webpack-dev-server or webpack watch mode. **Default: true**
* `safe`: switches script execution process from spawn to exec. If running into problems with spawn, turn this setting on. **Default: false**

**Note:** below combination is not supported.
```
{
blocking: true
parallel: true
}
```


### Developing

If opening a pull request, create an issue describing a fix or feature. Have your pull request point to the issue by writing your commits with the issue number in the message.
Expand All @@ -94,4 +81,14 @@ Make sure you lint your code by running `npm run lint` and you can build the lib
I appreciate any feed back as well, Thanks for helping!

### Contributions
Yair Tavor
Pavel Kuzmin

## Change Log

### 0.7.0
```
- add ts
- add onBeforeBuild and onBuildExit
- add logging, swallowError, dev
```

27 changes: 27 additions & 0 deletions lib/index.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
/**
* @class WebpackShellPluginNext
* @extends Object
* Run shell commands before and after webpack builds
*/
import { Options } from './types';
import * as webpack from 'webpack';
export default class WebpackShellPlugin {
private options;
constructor(options: Options);
private putsAsync;
private puts;
private spreadStdoutAndStdErr;
private serializeScript;
private handleScript;
private handleScriptAsync;
private executeScripts;
private validateInput;
private mergeOptions;
apply(compiler: webpack.Compiler): void;
private readonly onInvalid;
private readonly onCompilation;
private readonly onAfterEmit;
private readonly onDone;
private log;
private warn;
}
Loading

0 comments on commit 5744ebc

Please sign in to comment.