File tree Expand file tree Collapse file tree 2 files changed +16
-2
lines changed Expand file tree Collapse file tree 2 files changed +16
-2
lines changed Original file line number Diff line number Diff line change @@ -112,9 +112,14 @@ class ServerlessWebpack {
112112 'before:invoke:local:invoke' : ( ) => BbPromise . bind ( this )
113113 . then ( ( ) => {
114114 lib . webpack . isLocal = true ;
115+ // --no-build override
116+ if ( this . options . build === false ) {
117+ this . skipCompile = true ;
118+ }
119+
115120 return this . serverless . pluginManager . spawn ( 'webpack:validate' ) ;
116121 } )
117- . then ( ( ) => this . serverless . pluginManager . spawn ( 'webpack:compile' ) )
122+ . then ( ( ) => this . skipCompile ? BbPromise . resolve ( ) : this . serverless . pluginManager . spawn ( 'webpack:compile' ) )
118123 . then ( this . prepareLocalInvoke ) ,
119124
120125 'after:invoke:local:invoke' : ( ) => BbPromise . bind ( this )
@@ -181,7 +186,7 @@ class ServerlessWebpack {
181186 lib . webpack . isLocal = true ;
182187 } )
183188 . then ( this . prepareStepOfflineInvoke )
184- . then ( this . compile )
189+ . then ( ( ) => this . serverless . pluginManager . spawn ( 'webpack: compile' ) ) ,
185190 } ;
186191 }
187192}
Original file line number Diff line number Diff line change @@ -143,6 +143,15 @@ module.exports = {
143143 this . webpackConfig . output . path = path . join ( this . serverless . config . servicePath , this . options . out ) ;
144144 }
145145
146+ if ( this . skipCompile ) {
147+ this . serverless . cli . log ( 'Skipping build and using existing compiled output' ) ;
148+ if ( ! fse . pathExistsSync ( this . webpackConfig . output . path ) ) {
149+ return BbPromise . reject ( new this . serverless . classes
150+ . Error ( 'No compiled output found' ) ) ;
151+ }
152+ this . keepOutputDirectory = true ;
153+ }
154+
146155 if ( ! this . keepOutputDirectory ) {
147156 this . options . verbose && this . serverless . cli . log ( `Removing ${ this . webpackConfig . output . path } ` ) ;
148157 fse . removeSync ( this . webpackConfig . output . path ) ;
You can’t perform that action at this time.
0 commit comments