File tree Expand file tree Collapse file tree 1 file changed +18
-5
lines changed
Expand file tree Collapse file tree 1 file changed +18
-5
lines changed Original file line number Diff line number Diff line change 11#!/usr/bin/env node
22
3- const path = require ( 'path' ) ;
4- const { spawn } = require ( 'child_process' ) ;
3+ const fs = require ( 'fs' )
4+ const path = require ( 'path' )
5+ const { spawn } = require ( 'child_process' )
56
6- const webpackConfig = path . resolve ( __dirname , 'webpack.config.js' )
7+ const webpackConfigPath = path . resolve ( __dirname , 'webpack.config.js' )
8+ let webpackBinPath = path . resolve ( __dirname , 'node_modules/webpack/bin/webpack.js' )
79
8- spawn ( `${ __dirname } /node_modules/webpack/bin/webpack.js serve --config ${ webpackConfig } --open` , [ ] , {
10+ if ( ! fs . existsSync ( webpackBinPath ) ) {
11+ // when using newer versions of npx, node modules are not inside swift-react folder
12+ webpackBinPath = path . resolve ( __dirname , '../webpack/bin/webpack.js' )
13+ }
14+
15+ if ( ! fs . existsSync ( webpackBinPath ) ) {
16+ console . log ( `\nCouldn't find webpack binary to start webpack server. Please raise an issue at https://github.com/mesaugat/swift-react/issues` )
17+
18+ process . exit ( 1 )
19+ }
20+
21+ spawn ( `${ webpackBinPath } serve --config ${ webpackConfigPath } --open` , [ ] , {
922 shell : true ,
1023 stdio : 'inherit'
11- } ) ;
24+ } )
You can’t perform that action at this time.
0 commit comments