Skip to content

Commit 71fa92b

Browse files
committed
Merge pull request #3 from 1337programming/feature/hmr-support
hot module support for dev environments.
2 parents ff1742a + 471e6f6 commit 71fa92b

File tree

2 files changed

+13
-1
lines changed

2 files changed

+13
-1
lines changed

README.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,11 @@ module.exports = config;
4646
```
4747
Once the build finishes, a child process is spawned firing both a python and node script.
4848

49+
### API
50+
* onBuildStart: **Array[]**, array of scripts to execute on the initial build. **Default: []**
51+
* onBuildEnd: **Array[]**, array of scripts to execute after files are emitted. **Default: []**
52+
* dev: **Boolean**, switch for development environments. This causes scripts to only execute once. Useful for running HMR on webpack-dev-server. **Default: false**
53+
4954
Enjoy
5055

5156
### Contributions

index.js

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,8 @@ function puts(error, stdout, stderr) {
77
function WebpackShellPlugin(options) {
88
var defaultOptions = {
99
onBuildStart: [],
10-
onBuildEnd: []
10+
onBuildEnd: [],
11+
dev: false
1112
};
1213
if (!options.onBuildStart) {
1314
options.onBuildStart = defaultOptions.onBuildStart;
@@ -28,13 +29,19 @@ WebpackShellPlugin.prototype.apply = function(compiler) {
2829
if(options.onBuildStart.length){
2930
console.log("Executing pre-build scripts");
3031
options.onBuildStart.forEach(function (script) { exec(script, puts)});
32+
if (options.dev) {
33+
options.onBuildStart = [];
34+
}
3135
}
3236
});
3337

3438
compiler.plugin("emit", function (compilation, callback) {
3539
if(options.onBuildEnd.length){
3640
console.log("Executing post-build scripts");
3741
options.onBuildEnd.forEach(function(script){ exec(script, puts)});
42+
if (options.dev) {
43+
options.onBuildEnd = [];
44+
}
3845
}
3946
callback();
4047
});

0 commit comments

Comments
 (0)