Created
April 10, 2016 07:39
-
-
Save zetavg/b26c47cd6ee434347ceb151cb7e0415a to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 'use strict'; | |
| var exec = require('child_process').exec; | |
| function log(error, stdout, stderr) { | |
| console.log(stdout); | |
| } | |
| function ShellScriptWebpackPlugin(options) { | |
| var defaultOptions = { | |
| onBuildStart: [], | |
| onBuildEnd: [] | |
| }; | |
| this.options = Object.assign(defaultOptions, options); | |
| } | |
| ShellScriptWebpackPlugin.prototype.apply = function(compiler) { | |
| const options = this.options; | |
| compiler.plugin("compilation", compilation => { | |
| if(options.onBuildStart.length){ | |
| options.onBuildStart.forEach(script => exec(script, log)); | |
| } | |
| }); | |
| compiler.plugin("emit", (compilation, callback) => { | |
| if(options.onBuildEnd.length){ | |
| options.onBuildEnd.forEach(script => exec(script, log)); | |
| } | |
| callback(); | |
| }); | |
| }; | |
| module.exports = ShellScriptWebpackPlugin; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment