File tree 2 files changed +15
-4
lines changed
2 files changed +15
-4
lines changed Original file line number Diff line number Diff line change @@ -22,6 +22,7 @@ import {
22
22
} from '../lib/configuration/defaults' ;
23
23
import { FileSystemReader } from '../lib/readers' ;
24
24
import { ERROR_PREFIX } from '../lib/ui' ;
25
+ import { isModuleAvailable } from '../lib/utils/is-module-available' ;
25
26
import { AbstractAction } from './abstract.action' ;
26
27
import webpack = require( 'webpack' ) ;
27
28
@@ -261,13 +262,15 @@ export class BuildAction extends AbstractAction {
261
262
webpackRef : typeof webpack ,
262
263
) => webpack . Configuration {
263
264
const pathToWebpackFile = join ( process . cwd ( ) , webpackPath ) ;
265
+ const isWebpackFileAvailable = isModuleAvailable ( pathToWebpackFile ) ;
266
+ if ( ! isWebpackFileAvailable && webpackPath === defaultPath ) {
267
+ return ( { } ) => ( { } ) ;
268
+ }
269
+
264
270
try {
265
271
return require ( pathToWebpackFile ) ;
266
272
} catch ( err ) {
267
- if ( webpackPath !== defaultPath ) {
268
- throw err ;
269
- }
270
- return ( { } ) => ( { } ) ;
273
+ throw err ;
271
274
}
272
275
}
273
276
}
Original file line number Diff line number Diff line change
1
+ export function isModuleAvailable ( path : string ) : boolean {
2
+ try {
3
+ require . resolve ( path ) ;
4
+ return true ;
5
+ } catch {
6
+ return false ;
7
+ }
8
+ }
You can’t perform that action at this time.
0 commit comments