File tree Expand file tree Collapse file tree 2 files changed +15
-4
lines changed Expand file tree Collapse file tree 2 files changed +15
-4
lines changed Original file line number Diff line number Diff line change @@ -22,6 +22,7 @@ import {
2222} from '../lib/configuration/defaults' ;
2323import { FileSystemReader } from '../lib/readers' ;
2424import { ERROR_PREFIX } from '../lib/ui' ;
25+ import { isModuleAvailable } from '../lib/utils/is-module-available' ;
2526import { AbstractAction } from './abstract.action' ;
2627import webpack = require( 'webpack' ) ;
2728
@@ -261,13 +262,15 @@ export class BuildAction extends AbstractAction {
261262 webpackRef : typeof webpack ,
262263 ) => webpack . Configuration {
263264 const pathToWebpackFile = join ( process . cwd ( ) , webpackPath ) ;
265+ const isWebpackFileAvailable = isModuleAvailable ( pathToWebpackFile ) ;
266+ if ( ! isWebpackFileAvailable && webpackPath === defaultPath ) {
267+ return ( { } ) => ( { } ) ;
268+ }
269+
264270 try {
265271 return require ( pathToWebpackFile ) ;
266272 } catch ( err ) {
267- if ( webpackPath !== defaultPath ) {
268- throw err ;
269- }
270- return ( { } ) => ( { } ) ;
273+ throw err ;
271274 }
272275 }
273276}
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