@@ -37,35 +37,38 @@ describe("HotTestCases", () => {
3737 updateIndex : 0
3838 }
3939 } ;
40- const options = {
41- context : testDirectory ,
42- entry : "./index.js" ,
43- output : {
44- path : outputDirectory ,
45- filename : "bundle.js"
46- } ,
47- module : {
48- loaders : [ {
49- test : / \. j s $ / ,
50- loader : path . join ( __dirname , "hotCases" , "fake-update-loader.js" ) ,
51- enforce : "pre"
52- } , {
53- test : / \. c s s $ / ,
54- use : ExtractTextPlugin . extract ( {
55- fallback : "style-loader" ,
56- use : "css-loader"
57- } )
58- } ]
59- } ,
60- target : "async-node" ,
61- plugins : [
62- new webpack . HotModuleReplacementPlugin ( ) ,
63- new webpack . NamedModulesPlugin ( ) ,
64- new webpack . LoaderOptionsPlugin ( fakeUpdateLoaderOptions ) ,
65- new ExtractTextPlugin ( "bundle.css" )
66- ] ,
67- recordsPath : recordsPath
68- } ;
40+ const configPath = path . join ( testDirectory , "webpack.config.js" ) ;
41+ let options = { } ;
42+ if ( fs . existsSync ( configPath ) )
43+ options = require ( configPath ) ;
44+ if ( ! options . context ) options . context = testDirectory ;
45+ if ( ! options . entry ) options . entry = "./index.js" ;
46+ if ( ! options . output ) options . output = { } ;
47+ if ( ! options . output . path ) options . output . path = outputDirectory ;
48+ if ( ! options . output . filename ) options . output . filename = "bundle.js" ;
49+ if ( options . output . pathinfo === undefined ) options . output . pathinfo = true ;
50+ if ( ! options . module ) options . module = { } ;
51+ if ( ! options . module . rules ) options . module . rules = [ ] ;
52+ options . module . rules . push ( {
53+ test : / \. j s $ / ,
54+ loader : path . join ( __dirname , "hotCases" , "fake-update-loader.js" ) ,
55+ enforce : "pre"
56+ } , {
57+ test : / \. c s s $ / ,
58+ use : ExtractTextPlugin . extract ( {
59+ fallback : "style-loader" ,
60+ use : "css-loader"
61+ } )
62+ } ) ;
63+ if ( ! options . target ) options . target = "async-node" ;
64+ if ( ! options . plugins ) options . plugins = [ ] ;
65+ options . plugins . push (
66+ new webpack . HotModuleReplacementPlugin ( ) ,
67+ new webpack . NamedModulesPlugin ( ) ,
68+ new webpack . LoaderOptionsPlugin ( fakeUpdateLoaderOptions ) ,
69+ new ExtractTextPlugin ( "bundle.css" )
70+ ) ;
71+ if ( ! options . recordsPath ) options . recordsPath = recordsPath ;
6972 const compiler = webpack ( options ) ;
7073 compiler . run ( ( err , stats ) => {
7174 if ( err ) return done ( err ) ;
0 commit comments