@@ -127,6 +127,7 @@ class ServerlessReact {
127
127
progress = DEFAULT_PROGRESS ;
128
128
129
129
serverless : Serverless ;
130
+ serverlessConfig : ServerlessConfig ;
130
131
service : ServerlessService ;
131
132
pluginConfig : PluginConfig ;
132
133
configuration : {
@@ -141,6 +142,7 @@ class ServerlessReact {
141
142
constructor ( serverless : Serverless , protected options ?: Options ) {
142
143
this . serverless = serverless ;
143
144
this . service = serverless . service ;
145
+ this . serverlessConfig = serverless . config ;
144
146
this . pluginConfig =
145
147
( this . service . custom && this . service . custom [ PLUGIN_NAME ] ) || { } ;
146
148
@@ -197,23 +199,24 @@ class ServerlessReact {
197
199
"react:build" : async ( ) => {
198
200
console . log ( "!!!! react:build" ) ;
199
201
} ,
202
+ "before:offline:start:init" : async ( ) => {
203
+ this . log . verbose ( "before:offline:start:init" ) ;
204
+ await this . build ( ) ;
205
+ } ,
200
206
} ;
201
207
}
202
208
203
- build = async (
204
- serverlessConfig : ServerlessConfig ,
205
- pluginConfig : PluginConfig
206
- ) : Promise < void > => {
209
+ build = async ( ) : Promise < void > => {
207
210
const webpackConfig = path . join (
208
- serverlessConfig . servicePath ,
209
- pluginConfig . webpackConfig ||
211
+ this . serverlessConfig . servicePath ,
212
+ this . pluginConfig . webpackConfig ||
210
213
"node_modules/react-scripts/webpack.config.js"
211
214
) ;
212
215
213
216
const configFactory = ( await import ( webpackConfig ) ) . default ;
214
217
const config : Configuration = configFactory ( "production" ) ;
215
218
216
- config . entry = pluginConfig . entryPoint || config . entry ;
219
+ config . entry = this . pluginConfig . entryPoint || config . entry ;
217
220
218
221
const compiler = webpack ( config ) ;
219
222
0 commit comments