1- import CopyWebpackPlugin from 'copy-webpack-plugin' ;
2- var CommonsChunkPlugin = require ( 'webpack/lib/optimize/CommonsChunkPlugin' ) ;
31const webpack = require ( 'webpack' ) ;
4- const path = require ( 'path' )
5- const GitRevisionPlugin = require ( 'git-revision-webpack-plugin' )
2+ const path = require ( 'path' ) ;
3+ const GitRevisionPlugin = require ( 'git-revision-webpack-plugin' ) ;
4+ var WebpackBeforeBuildPlugin = require ( 'before-build-webpack' ) ;
5+ import WatchExternalFilesPlugin from 'webpack-watch-files-plugin'
6+
67const fsUtil = require ( './fs-util' ) ;
8+ const spawn = require ( 'child_process' ) . spawn ;
79
810/**
911 * Function that mutates original webpack config.
@@ -14,6 +16,18 @@ const fsUtil = require('./fs-util');
1416 * @param {WebpackConfigHelpers } helpers - object with useful helpers when working with config.
1517 **/
1618export default function ( config , env , helpers ) {
19+ config . plugins . push ( new WatchExternalFilesPlugin ( {
20+ files : [
21+ './main.js'
22+ ]
23+ } ) ) ;
24+ config . plugins . push ( new WebpackBeforeBuildPlugin ( function ( stats , callback ) {
25+ const child = spawn ( 'yarn' , [ 'webpack' ] ) ;
26+ child . stdout . on ( 'data' , data => process . stdout . write ( data ) ) ;
27+ child . stderr . on ( 'data' , data => process . stderr . write ( data ) ) ;
28+ child . on ( 'close' , code => process . stdout . write ( `yarn webpack exists with code ${ code } ` ) ) ;
29+ callback ( ) ;
30+ } ) ) ;
1731 const htmlWebpackPlugin = helpers . getPluginsByName (
1832 config ,
1933 'HtmlWebpackPlugin'
0 commit comments